[R] Any alternatives to draw.colorkey from lattice package?

Mikhail Titov mlt at gmx.us
Fri Aug 12 20:34:19 CEST 2011


Hello!

I’d like to have a continuous color bar on my lattice xyplot with colors lets say from topo.colors such that it has ticks & labels at few specific points only.

Right now I use do.breaks & level.colors with somewhat large number of steps. The problem is that color change point doesn’t necessary correspond to the value I’d like to label. Since I have many color steps and I don’t need high precision I generate labels like this

labels <- ifelse( sapply(at,function(x) any(abs(att-x)<.03)) , sprintf("depth= %s ft", at), "")

, where `att` has mine points of interest on color scale bar and `at` corresponds to color change points used with level.colors . It is a bit inconvenient as I have to adjust threshold `.03`, number of color steps so that it labels only adjacent color change point with my labels.

Q: Are there any ready to use functions that would generate some kind of GRaphical OBject with continuous color scale bar/key with custom at/labels such that it would work with `legend` argument of xyplot from lattice?

Mikhail



More information about the R-help mailing list