[R] need help with ordering of plots

Dieter Menne dieter.menne at menne-biomed.de
Wed Mar 25 18:19:26 CET 2009


Cable, Samuely <at> hanscom.af.mil> 

> I want to do a series of contour plots, 4 in all.  The data is coming
> from a data frame named "nd.frame", which has elements "xdf", "ydf",
> "zdf", and "pndt".  I am treating "pndt" as a factor, and it has four
> levels.  I make a call to the lattice graphics routine "contourplot"
> like so:
> 
> The problem - a big problem in my situation - is that the arrangement is
> in the order

I know, it's really a bit of guesswork which parameters work for special
plots. Nevertheless, if you are unsure, always look on the xyplot page 
and try one of the parameter there. Your friend is called as.table.

If you need a really crazy ordering, reorder your factor:

Dieter

#----------------------------------------------------
library(lattice)
x <- seq(pi/4, 5 * pi, length.out = 10)
y <- seq(pi/4, 5 * pi, length.out = 10)
r <- as.vector(sqrt(outer(x^2, y^2, "+")))
grid <- expand.grid(x=x, y=y)
grid$z <- cos(r^2) * exp(-r/(pi^3))
grid$class= rep(letters[1:4],each=25)
contourplot(z~x*y|class, grid, region = TRUE,as.table=TRUE)
grid$rclass = factor(grid$class,levels=c("c","b","a","d"))
contourplot(z~x*y|rclass, grid, region = TRUE,as.table=TRUE)




More information about the R-help mailing list