[R] xyplot Legend Title and Position

Dennis Murphy djmuser at gmail.com
Wed Jun 15 03:03:57 CEST 2011


Hi:

Part of the problem is that you have a point in the upper right corner
of your plot, so one way around it is to expand the y-range. Try this:

xyplot(Yield ~ Date,
      groups=Machine, ylim = c(7, 22),
      auto.key=list(title="Machine", corner = c(0.95, 1), cex=1.0),
       par.settings = list(superpose.symbol=list(pch = 0:18, cex=1)),
      )

HTH,
Dennis

On Tue, Jun 14, 2011 at 4:36 PM, Justin McBride <crazyhawk48 at gmail.com> wrote:
> Dear R Community,
>
> I'm using xyplot in Lattice with a legend and a title on the legend.
> The title on legend is being cut off, as can be seen by running the
> code below.   The legend is on the right, but I would like to get to
> the top right of the graphics window.  Is there a way to get the
> legend title to display correctly and move the whole legend up the the
> top right?
>
> Thanks,
> Justin
>
> ### R code
>
> library(lattice)
> Yield=c(16, 17, 11, 8, 16, 18)
> Date = c(1, 1, 2, 3, 4, 5)
> Machine = c(1, 3, 2, 2, 3, 1)
>
>
> xyplot(Yield ~ Date,
>       groups=Machine,
>       auto.key=list(title="Machine", space = "right", cex=1.0),
>        par.settings = list(superpose.symbol=list(pch = 0:18, cex=1)),
>       )
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list