Skip to content
Prev 243936 / 398506 Next

scale caption on levelplot

Andrew,
see below
On 2010-12-04 08:25, David Winsemius wrote:
As David says, you need to use trellis parameters, in this case
presumably trellis.par.get('layout.widths') and
trellis.par.get('layout.heights') will be useful. You can add
appropriate settings to your levelplot() call with the
par.settings argument. After you adjust the amount of space
you want, you can then use grid::grid.text() to add your text.
Here's an example:

   library(grid)
   x <- sort(rnorm(100,50,10))
   y <- sort(runif(100,0,20))
   d <- expand.grid(x=x, y=y)
   d$z <- x + y
   graphics.off()
   p <- levelplot(z ~ x*y, d,
             par.settings=list(
               layout.widths=list(right.padding=4),
               layout.heights=list(top.padding=6)),
             colorkey = TRUE)
   print(p)

   ## now add the text
   grid.text('here and there', x=.98, y=.5, rot=-90,
     gp = gpar(col=4,
         fontfamily="HersheyGothicEnglish", cex=2))
   grid.text('here\nand\nthere', x=.88, y=.92,
     gp = gpar(lineheight=.75, col=3))

Peter Ehlers