[R] Adding title to colorkey

Stephen Eglen S.J.Eglen at damtp.cam.ac.uk
Sat Jun 16 10:40:35 CEST 2012


A recent paper on visualisation (in Neuron, a leading neuroscience
journal) surveyed how well previous articles in this journal labelled their
graphs (e.g. axis labelling and describing their error bars).  Of
particular interest is that (only) 40% of plots labelled what their
colorkey was showing (variable and units).

The paper is at http://dx.doi.org/10.1016/j.neuron.2012.05.001

R is not yet that prominent (compared to matlab) in Neuroscience, so I
doubt many of the graphs were generated by levelplot() and friends.
However, how can the colorkey be labelled?  I notice that this topic has
been raised before, e.g.

  http://tolstoy.newcastle.edu.au/R/e16/help/11/11/2281.html

For now, I've done:

library(lattice)
library(grid)
levelplot(matrix(1:9,3,3),
          par.settings = list(layout.widths = list(axis.key.padding = 4)))
grid.text('title here', y=unit(0.5, "npc"),
          rot=90, x=unit(0.88, "npc"))

i.e. adding some space between levelplot and colorkey.  The
x,y positions of the grid.text call need fine-tuning once the plot is
close to finalised.  

Does anyone have a better solution for vertical colorkeys?  e.g. can the
plot objected be interrogated to work out what the central x,y value is?


Thanks, Stephen



More information about the R-help mailing list