[R] aligning column of xyplots and removing space between them

Gabor Grothendieck ggrothendieck at gmail.com
Wed Oct 12 01:44:28 CEST 2005


Thanks.  That works although the alignment is still not perfect.
I am attaching the saved image in both .png and .emf formats
so you can see what I mean.  Its not far off but its noticeable.

In .emf format a portion of the bounding box does not come out
either and it comes out bluish rather than white.  Not sure if such
attachments can survive the list but I have sent you a copy too just
in case.

Regards.

P.S. My R version is the following:

> packageDescription("lattice")$Version
[1] "0.12-10"
> R.version; R.version.string
         _
platform i386-pc-mingw32
arch     i386
os       mingw32
system   i386, mingw32
status   alpha
major    2
minor    2.0
year     2005
month    09
day      20
svn rev  35632
language R
[1] "R version 2.2.0, 2005-09-20"


On 10/11/05, Deepayan Sarkar <deepayan.sarkar at gmail.com> wrote:
> On 10/11/05, Gabor Grothendieck <ggrothendieck at gmail.com> wrote:
> > The code below displays three graphs in three rows and one column but:
> >
> > 1. I want to remove the space between the graphs (I tried playing with position=
> > arg to print.trellis but it seems quite difficult to get the right
> > values and all
> > my attempts had space between them or had overlapping graphs.  Is
> > there a better way to do this?
>
> Define
>
> theme.novpadding <- list(layout.heights =
>    list(top.padding = 0,
>         main.key.padding = 0,
>         key.axis.padding = 0,
>         axis.xlab.padding = 0,
>         xlab.key.padding = 0,
>         key.sub.padding = 0,
>         bottom.padding = 0))
>
> and then add
>
> par.settings = theme.novpadding
>
> to all your xyplot calls.
>
> > 2. the widths of the plots are not the same even though I specified the same
> > xlim= to them all.  How do I make them the same?
>
> They seem to be the same for me, but they might be different if the
> y-axis labels are different. See the 'panel.width' argument in
> ?print.trellis.
>
>
> > 3. how do I get rid of the ticks at the top of the bottom plot?
>
> add
>
> scales = list(x = list(relation = "free"))
>
> > 4. the bottom graph is supposed to plot 1:3 against itself but the third
> > point is not showing even though I specified ylim = c(0,3).  Must
> > I specify ylim = c(0,3+1) or is there a better way?
>
> There's no better way. This behaviour is intentionally different from
> base graphics.
>
> Here's a modified version of the last part of your code:
>
> grid.newpage()
>
> # n and nr are number of cells and rows
> n <- nr <- 3
> nc <- 1  # must be 1
>
> heights <- unit(c(2, rep(1, nr-1)), "null")
> downViewport(pushLayout(nr, nc, heights = heights))
>
> vpt <- current.vpTree(all = FALSE)
>
> ### relevant part starts here
> #########################
>
> xlab <- main <- function(x) if (x) "v"
> for(k in 1:n) with(vpt$children[[k]],
>       print( xyplot(v ~ v, list(v = 1:k), xlab = xlab(k == n),
>       xlim = c(0,n), ylim = c(0,n), main = main(k == 1),
>       par.settings = theme.novpadding,
>       scales = list(x = list(draw = k == n, relation = "free", c(1, 0)),
>                         y = list(alternating = 3))),
>       newpage = FALSE, panel.width = list(x = 4, units = "inches"))
> )
>
> -Deepayan
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.png
Type: image/png
Size: 6728 bytes
Desc: not available
Url : https://stat.ethz.ch/pipermail/r-help/attachments/20051011/2d9f6cc8/test.png


More information about the R-help mailing list