[R] Can levelplot colorkeys display a logarithmic scale evenly?

Mike MacFerrin Michael.MacFerrin at Colorado.EDU
Fri Jan 6 04:28:56 CET 2012


I'm using the {lattice} "levelplot" function to make a (more or less) 2-d 
histogram, and for the most part it's working fine with my data.  However, I 
can't get the color key to do what I need.  I can give it labels and custom 
cutoffs, but my cutoff lines (and hence my labels) aren't evenly spaced, instead 
they're more-or-less logarithmic, starting at [0,20,50,100...] and continuing on 
up to 5 million.

Levelplot scales the ticks/labels linearly on the color key, leaving most my 
labels scrunched down atop each other at the bottom and only the last few 
(..."500K","1M","2M","5M") really visible on the rest of the key.  I want each 
gap (no matter its numerical range) to occupy one evenly-spaced "block" on the 
color key, so they're all readable by the user.  I want it to display value on a 
logarithmic scale (0,1,10,100,1000,...).  The colorkey only seems to support 
linear scales (0,2,4,6,8,10,...), at least by default, and I don't see any 
options in the help to change that default.

Does levelplot support this?  Or am I destined to draw the colorkey manually 
(very painfully using polygon calls and user coordinates)?  Or are there other 
levelplot-like functions that would facilitate this?  Any help is appreciated,

- Mike



More information about the R-help mailing list