[R] Contour plot overlayed with line plot

Jonathan Greenberg jgreenberg at arc.nasa.gov
Thu May 11 05:24:10 CEST 2006

Keeping with the "newbie" questions -- I'm having a hard time figuring out
how to order the data -- I have x,y,z triplets, but I'm getting this error:

...increasing 'x' and 'y' values expected

I saw in the documentation they should be ordered, but a) how do I do this,
and b) do I need to sort by x first then y?  




Jonathan A. Greenberg, PhD
NRC Research Associate
NASA Ames Research Center
MS 242-4
Moffett Field, CA 94035-1000
Phone: 415-794-5043
AIM: jgrn3007
MSN: jgrn3007 at hotmail.com

-----Original Message-----
From: Duncan Murdoch [mailto:murdoch at stats.uwo.ca] 
Sent: Wednesday, May 10, 2006 7:43 PM
To: Jonathan Greenberg
Subject: Re: [R] Contour plot overlayed with line plot

On 5/10/2006 7:46 PM, Jonathan Greenberg wrote:
> I apologize for what may be a newbie question: I have two sets of data,
> is X,Y,Z data that I'd like to make a contour plot of (Z defining the
> contours), and a second set of X,Y data (Y as a function of X) which I
> like made into a line plot OVERLAYED on the contour plot (X and Y from
> plots are in the same units and will have overlapping values).  Any
> suggestions on how to do this in R?  Thanks!\

Use contour() first in the usual way, then use the lines() function to 
add lines to it. (Or points(), etc.)

Duncan Murdoch

More information about the R-help mailing list