[R] Origin label in lattice
Deepayan Sarkar
deepayan.sarkar at gmail.com
Thu Sep 13 22:39:45 CEST 2007
On 9/13/07, Andrew Smith <andrewsmith81 at gmail.com> wrote:
> I would like to make what seems like a simple addition to a display
> constructed from a call to levelplot -- I want to add a text label
> (which will, in general, depend on the object being plotted, and so
> cannot be hardcoded) to the origin, which has special significance in
> my problem. The x and y axes always have range (0,1) in my plots, so
> by "origin" I always mean the lower left corner of the plot. Now, I
> can add text to the inside of the panel using panel.text, but this
> clutters the plot and I find it unsatisfactory. What I would like is
> to add the label outside of the panel, just below and to the left of
> the lower left corner of the panel. I've unsuccessfully tried to do
> this using the xscale.components argument, and I'm having trouble
> figuring out which other arguments or functions might be helpful. I
> would greatly appreciate any advice!
You can either turn off clipping in panels with
trellis.par.set(clip = list(panel = "off"))
or use the axis function:
levelplot(volcano,
axis = function(side, ...) {
axis.default(side, ...)
if (side == "bottom")
panel.text(0, 0, lab = "label", adj = c(1, 1))
})
(axis gets called once for every side in every panel, so you have to
make sure you do it only for one side.)
-Deepayan
More information about the R-help
mailing list