Hi Dieter,
Thank you for that! Your post helped me on my way by introducing me to the
padding settings within lattice, and I'm nearly there now.
My new problem related to this graph is that I would like to add a polygon to
one of the panels, but it seems that my code also adds the polygon to the
paired panel. Is there a way to condition it so that it only appears on the
top panel in column 3?
Here is my updated code:
start = expand.grid(1:10,1:14)
start2 = rbind(start,start,start,start,start,start)
z = rnorm(840)
factor.1 = c(rep("A", 280), rep("B", 280), rep("C", 280))
factor.2 = c(rep("1", 140), rep("2", 140), rep("1", 140), rep("2", 140),
rep("1", 140), rep("2", 140))
data = data.frame(start2, z, factor.1, factor.2)
names(data)[1:2] = c("x", "y")
data.A = data[data$factor.1 == "A",]
data.B = data[data$factor.1 == "B",]
data.C = data[data$factor.1 == "C",]
plot.A = levelplot(z~x*y|1*factor.2,data.A,col.regions=heat.colors, strip =
FALSE, asp="iso",xlab = "", ylab = "", colorkey = list(space="bottom"),
scales=list(y=list(draw=F),x=list(draw=F)))
plot.B = levelplot(z~x*y|1*factor.2,data.B,col.regions=topo.colors, strip =
FALSE, asp="iso",xlab = "", ylab = "", colorkey = list(space="bottom"),
scales=list(y=list(draw=F),x=list(draw=F)))
plot.C = levelplot(z~x*y|1*factor.2,data.C,col.regions=terrain.colors, strip =
FALSE, asp="iso",xlab = "", ylab = "", colorkey = list(space="bottom"),
scales=list(y=list(draw=F),x=list(draw=F)),
panel = function(x, y, subscripts, ...) {
panel.levelplot(x, y, subscripts, ...)
panel.polygon(c(2, 5, 5, 2), c(3, 3, 8, 8), col="blue")
}
)
print(plot.A, split=c(1,1,3,1))
print(plot.B, split=c(2,1,3,1), newpage = FALSE)
print(plot.C, split=c(3,1,3,1), newpage = FALSE)
Thanks again for your help!
[[alternative HTML version deleted]]
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.