[R] aligning axis labels in a colorkey from levelplot

Stephen Eglen S.J.Eglen at damtp.cam.ac.uk
Tue Jun 26 08:25:50 CEST 2012


Deepayan Sarkar <deepayan.sarkar at gmail.com> writes:


> You can specify a fixed-width fontfamily if that helps:
>
> levelplot(matrix(seq(4,120,l=9),3,3),
>           colorkey = list(at = seq(0, 120, 20),
>                           labels = list(labels = c('  0',' 20',' 40','
> 60',' 80','100','120'),
>                                         fontfamily = "courier",
>                                         font = 1)))

Thanks Deepayan; I think I finally found a solution which worked much
easier than I thought:

## Thanks to "R graphics, 2nd ed" Paul Murrell, page 250 shows how to edit
## an existing plot.
levelplot(matrix(-90:89,20,20))
grid.edit("[.]colorkey.labels$", grep=TRUE, just="right",
          global=T, x=unit(0.95, "npc"))

I can live with adjusting the x position by hand.

Stephen



More information about the R-help mailing list