Skip to content
Prev 263232 / 398502 Next

xyplot Legend Title and Position

On Wed, Jun 15, 2011 at 6:32 PM, Justin McBride <crazyhawk48 at gmail.com> wrote:
One option is:

xyplot(Yield ~ Date,
       groups=Machine,
       auto.key=list(title="Machine", space = "top", cex=1.0, just = 0.95),
       par.settings = list(superpose.symbol=list(pch = 0:18, cex=1)))

Strictly speaking, this places the legend right-justified on the top
(which is not quite the top-right corner). The other option, which
gives you more flexibility, but needs you to control space manually,
is

xyplot(Yield ~ Date,
       groups=Machine,
       auto.key=list(title="Machine", corner = c(1, 1), x = 0.95, y =
1, cex=1.0),
       par.settings = list(superpose.symbol=list(pch = 0:18, cex=1),
                           layout.heights = list(top.padding = 8),
                           layout.widths = list(right.padding = 8)),
       lattice.options = list(legend.bbox = "full")
       )


-Deepayan