[R] scale caption on levelplot

David Winsemius dwinsemius at comcast.net
Sat Dec 4 17:25:58 CET 2010

On Dec 4, 2010, at 8:25 AM, Andrew Collier wrote:

> hi,
> i am trying to figure out how to put a caption on the colour scale  
> of a
> levelplot. there does not seem to be an option for this in  
> levelplot().

Agreed. I could not find one in the levelplot help page or in the  
chapter of Lattice on legends and keys. Sarkar basically says you need  
to use grid calls if you want to go beyond the basics.

> i tried using mtext() but as soon as you put the text far out enough  
> on
> the right of the plot, it goes beyond the plot boundary. so i tried to
> extend the margin on the right of the plot using par(mar) but this did
> not have any effect on the plot area.
> i would really appreciate some help with this because having a caption
> on a colour scale is rather fundamental and certainly something that a
> journal referee is going to pick up on!

Your question has no reproducible example but suggests that you do not  
understand that levelplot is a lattice function and that lattice uses  
grid graphics. The par arguments that lattice understands (or is  
willing to deal with gracefully) are passed through trellis.par.set().  
The current settings are accessible with:


  Since lattice is implemented with grid graphics, you may get useful  
information from:

require(grid)   # lattice apparently loads gpar and its help page but  
                 # actually load grid. (I don't understand this. )
?gpar()   # Which has examples that may allow you to get a better  
           # of how to layer new material on top of existing grid  


David Winsemius, MD
West Hartford, CT

More information about the R-help mailing list