Duncan (and others):
I figured it out (thank you!), I ended up doing a
contour(interp(x,y,z)), and I did figure out lines(), but I can't get the
output of lines to "sync" with the proper coordinates of the contour()
output (its overlaying the line over the contour plot, but not in the proper
location). Any ideas?
--j
--
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 8:41 PM
To: Jonathan Greenberg
Subject: Re: [R] Contour plot overlayed with line plot
On 5/10/2006 11:24 PM, Jonathan Greenberg wrote:> 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?
I think you don't understand the requirements of contour(). It wants
the z values to be in an M x N matrix, and x to be a vector of length N,
y a vector of length M. (Or did I get those transposed? It's late...)
The x values are the x coordinates of each column of z, the y values are
the y coordinates of them.
If you have triplets (x,y,z) of data that you want to plot as a surface,
you need to convert them to the form above, e.g. using the interp()
function from the akima package.
If I completely misunderstood your question: you can use the sort()
function to order x and y.
Duncan Murdoch>
> Thanks!
>
> --j
>
> --
>
> 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,
> one
>> 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
> would
>> like made into a line plot OVERLAYED on the contour plot (X and Y from
> both
>> 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
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html