You don't show code or a reproducible example, so I guess you want a
general answer. Use the draw.colorkey() function inside the
levelplot() call. It takes an argument key =, which accepts a list of
arguments, including space, col, at, labels, tick.number, width and
height (see p. 155 of the Lattice book). More specifically, the labels
argument also accepts a list of values, with components at, labels,
cex, col, font, fontface and fontfamily. You could attach the units as
labels with a combination of at = and labels = inside the (outer)
labels argument, something like
myAt <- c(1, 3, 5, 7, 9)
myLab <- paste(myAt, 'cm')
levelplot( ...
draw.colorkey(key = list(labels = list(at = myAt, labels = myLab)),
... )
If that doesn't work, then please provide a reproducible example.
HTH,
Dennis
On Mon, Nov 14, 2011 at 12:34 PM, Carlisle Thacker
<Carlisle.Thacker at noaa.gov> wrote:> How to add units (e.g. "cm") to the color key of a lattice
levelplot?
>
> The plots looks fantastic, but it would be nice to indicate somewhere near
> the end of the color key that the values associated with its colors are in
> centimeters or some other physical units.
>
> The only thing I find is the possibility to specify the labels so that one
> explicitly includes the units. ?That leaves little flexibility for
> positioning where this information appears. ?Is there a better way?
>
> ______________________________________________
> R-help at r-project.org 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.
>