[R] mtext in trellis-loop & colorkey
Deepayan Sarkar
deepayan.sarkar at gmail.com
Mon May 29 15:48:28 CEST 2006
On 5/29/06, Marius Hofert <m_hofert at web.de> wrote:
> Hello,
>
> I would like to create a sequence of plots (using a for loop). I read
> in the FAQ that print() has to be used in order to obtain any output.
> This works perfectly fine as long as I only consider one function
> call in the loop, but I would like to add mtext() to the each plot in
> the loop. Unfortunately, this did not work. Any suggestions?
Others have already responded to this.
> As you can see from the provided example, there is another problem
> with such animations: You do not see any difference in the plots
> (because only the "height" changes). Is there any possibility to keep
> a fixed scale for the colorkey (fixed labels and also fixed colors)
> and to see the different heights of the function from the colors
> (e.g. the first plot should be mainly gray (as it is the "lowest"),
> the last one mainly white (as it is the "highest")).
It seems to me that you are missing the primary point of Trellis
graphics, which is not having to manually manage such details in a
multipanel plot. Consider the following (which should produce 4 files
with a png device):
library(lattice)
x<-rep(seq(-3,3,length=50),50)
y<-rep(seq(-3,3,length=50),each=50)
z1 <- x * y + 10 * 1
z2 <- x * y + 10 * 2
z3 <- x * y + 10 * 3
z4 <- x * y + 10 * 4
wireframe(z1 + z2 + z3 + z4 ~ x * y,
outer = TRUE,
drape = TRUE,
zlab = "z",
layout = c(1, 1),
distance=0,zoom=0.84,
cuts=100,
col.regions=gray(100:400/400),
colorkey=list(tick.number=6))
Caveat: this won't work if you want the z-axis completely filled up in
each panel.
-Deepayan
More information about the R-help
mailing list