[R] contour plots

dbeest detebeest at hotmail.com
Tue Jun 22 15:29:35 CEST 2010


Hi All,

I'm having difficulty making a contour plot a would like some help.

A standard contourplot can be made by having an x,y, and some matrix (shape
x*y) with contents:

x = 1:10
y = 1:10
cont <- matrix(runif(100,min=1,max=2),nrow=10,ncol=10)
filled.contour(x,y,cont)

Looks very nice.


Sometimes data comes in a different format however. Basically an x and an y,
and a vector z with all realisations of some f(x,y). The only R way of
making a contour plot out of this I can find is: 

library(lattice)
x = runif(100,min=0,max=10)
y = runif(100,min=0,max=10)
z = runif(100,min=0,max=2)
contourplot(z ~ x * y, region = TRUE)

which is pretty ugly. And I don't think it needs to be. Does anyone know a
way to make plots of the first type with data of the second type?

Increasing the number of points to see if that fits better:
x = runif(1000,min=0,max=10)
y = runif(1000,min=0,max=10)
z = runif(1000,min=0,max=2)
contourplot(z ~ x * y, region = TRUE)

...hang on that doesn't plot anything: not my main question, but if anyone
cares to explain why that is..

cheers,

Dennis

-- 
View this message in context: http://r.789695.n4.nabble.com/contour-plots-tp2264113p2264113.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list