[R] Re: FW: Contour v Contourplot
Mark Myatt
mark at myatt.demon.co.uk
Fri May 31 13:56:52 CEST 2002
Phil,
You write:
>> Using x,y, and z variables in the enclosed test.RData, the command
>>
>> contour(x,y,z)
>>
>> produces a lovely 2D plot, whereas
>>
>> contourplot(z~x*y)
>>
>> produces the error..
>>
>> Error in if (lim[1] > lim[2]) stop("Improper value of limit") :
>> missing value where logical needed
>>
>> Any ideas what I'm doing wrong? Many thanks..
Well this took a bit of thought as I am not familiar with lattice. Gave
me the prod I needed to look at it and it was well worth the look.
The lattice functions seem want to have a data.frame rather than a list
of vectors. It doesn't say that in the docs (not that I found but I
didn't look far) so I did:
load("Test.RData")
phils.data <- expand.grid(x = x, y = y)
phils.data$z <- z
contourplot(z ~ x * y, data = phils.data)
And it worked. The trick is to use expand.grid() to create data.frame
containing one row for each combination x and y and then add z to that.
I think that is what you want.
Use:
lset(col.whitebg())
Before plots to get rid of the grey background ... better, IMHO)
I think the problem posting to R-Help might be down to your sending an
attachment.
Best wishes,
Mark
--
Mark Myatt
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list