Jan Verbesselt
2006-Jan-09 14:28 UTC
[R] How to use filled.contour(x,y,z) data for levelplot(z)?
Dear all, We used the following function to create a spatial plot of a raster image: filled.contour(xx,yy,zz, color = terrain.colors, nlevels=10, main=naamjaar, plot.axes = { contour(Xcoord/1000,Ycoord/1000,lim.data, nlevels = 4, col=4,drawlabels = T, axes = FALSE, frame.plot = FFALSE, add = TRUE);axis(1); axis(2); points(fire[,2:3]/1000,col="red",pch="*",cex=2,lwd=3) }) we however would like to create 5 maps with only one legend. This seems not to be possible with filled.contour follow the help(). We therefore started looking at levelplot(zz) to create a multipanel view. *However how could we use x and y coordinates in levelplot without using a formula (since x,y are only the coordinates of the matrix z)? libary(lattice) rownames(zz) <- xx colnames(zz) <- yy levelplot(zz) like this the all the row and col names are displayed in x and y axis without summarizing data similar to filled.contour function? * or can this be done with an upgrade of filled.contour? Thanks, Jan windows R 2.2 Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
Edzer J. Pebesma
2006-Jan-09 16:03 UTC
[R] How to use filled.contour(x,y,z) data for levelplot(z)?
Jan, libary(lattice) rownames(zz) <- xx colnames(zz) <- yy levelplot(zz) will not work -- levelplot needs a data frame with zz, xx and yy values next to each other, so read about data.frame(), rep() and as.vector(zz); you will need the each= argument for one of xx or yy. Sounds like you'd be helped by using package sp, see also http://r-spatial.sourceforge.net/ and look for the graph gallery, function spplot. -- Edzer