Re: [R] mtext in trellis-loop & colorkey

From: Deepayan Sarkar <deepayan.sarkar_at_gmail.com>
Date: Mon 29 May 2006 - 23:48:28 EST

On 5/29/06, Marius Hofert <m_hofert@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



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Mon May 29 23:53:56 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 30 May 2006 - 02:10:24 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.