[R] Text Outside Lattice Plot
Richard.Cotton at hsl.gov.uk
Richard.Cotton at hsl.gov.uk
Wed Jan 21 11:05:08 CET 2009
> I created the graph at the bottom using xyplot in the lattice package. I
> added a title using the main="Title" command in xyplot, however it is
> plotted too close to the legend for my liking. To remedy this I
increased
> the upper margin of the plot using plot(data, position = c(0,0,1,.9))
and
> attempted to move "SNA" upwards and to the right. I have tried using a
> variety of text functions such as:
>
> trellis.focus("panel", 1, 1)
> panel.text(x=11, y=100000, labels="SNA")
> trellis.unfocus()
>
> panel.xyplot(...)
> panel.text(x=11, y=100000, labels="SNA")
>
> library(grid)
> ltext(grid.locator(), label='SNA')
>
> The first two of these functions work but the text disappears once I
specify
> a y coordinate > ymax. The last function appears to work but requires
me to
> click on the plot to specify the location (I need this to be
pre-defined).
> Does anyone know how I can do this?
A simple way to get more space for the title is to change the layout
height parameter. Here's an adaptation of the OrchardSprays example in
?xyplot.
xyplot(decrease ~ treatment, OrchardSprays, groups = rowpos,
type = "a",
auto.key =
list(space = "top", points = FALSE, lines = TRUE),
main="Orchard sprays example",
par.settings=list(layout.heights=list(main=4)))
Regards,
Richie.
Mathematical Sciences Unit
HSL
------------------------------------------------------------------------
ATTENTION:
This message contains privileged and confidential inform...{{dropped:20}}
More information about the R-help
mailing list