Re: [R] Spacing between lattice panels

From: Deepayan Sarkar <deepayan.sarkar_at_gmail.com>
Date: Tue, 06 May 2008 07:06:48 -0700

On 5/6/08, Richard.Cotton_at_hsl.gov.uk <Richard.Cotton_at_hsl.gov.uk> wrote:
> I'm trying to set up a lattice plot with two y-axes for each panel. (Yes,
> I know that multiple y-axes are generally a bad idea; the graph is for
> someone else and they want it that way.) I've used a custom
> yscale.component in xyplot to achieve this:
>
> myyscale.component <- function(...)
> {
> ans <- yscale.components.default(...)
> ans$right <- ans$left
> foo <- ans$right$labels$at
> ans$right$labels$labels <- as.character(10*foo)
> ans
> }
>
> xyplot(Sepal.Length ~ Petal.Length| Species, data = iris, scales =
> list(y=list(relation="free", alternating=3, rot=0)),
> yscale.component=myyscale.component)
>
> The problem is that the panels are too close together. This appears to be
> because (according to the help documentation) xyplot ignores the
> alternating argument when relation is not "same". I presume that manually
> setting some plotting parameters with trellis.par.set() will allow me to
> adjust the spacing between the panels, though I can't figure out which
> ones to change.
>
> Is there a way to get lattice to properly space the panels,

No.

> or failing that, how do I manually space them?

The space between panels can be controlled using the 'between' argument. You additionally need some space at the right, for which you need to set a width component. E.g.,

xyplot(Sepal.Length ~ Petal.Length| Species, data = iris,

      scales = list(y=list(relation="free", alternating=3, rot=0)),
      yscale.component=myyscale.component,
      between = list(x = 2),
      par.settings = list(layout.widths = list(right.padding = 5)))

The full list of components of 'layout.widths' is given by

names(trellis.par.get("layout.widths"))

-Deepayan



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. Received on Tue 06 May 2008 - 14:14:12 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 06 May 2008 - 14:30:36 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive