[R] reducing space between charts in lattice graphics

Deepayan Sarkar deepayan.sarkar at gmail.com
Wed Sep 30 08:35:24 CEST 2009


On Sat, Sep 19, 2009 at 9:42 AM, Larry White <ljw1001 at gmail.com> wrote:
> Hi,
>
> I'm trying to create a lattice plot with three xyplots in one vertical
> column. I would like to reduce the vertical space between the charts.  My
> code is below. There seems to be a "between" parameter for lattice.options,
> but I can't find any examples. Aside from the data setup, the code is below.
> Can anyone provide an example showing how to reduce the white space between
> the charts?  Thanks.

There are a bunch of "*.padding" settings that you can change to
control spacing in lattice plots; e.g., see

str(trellis.par.get("layout.heights"))

But you are probably not using lattice as effectively as you might;
consider this single call as an alternative:

xyplot(total + bal + index ~ date, outer = TRUE, layout = c(1, 3),
scales = list(y = "free"))

You'll need a bit more (a custom panel function) to get different
color/pch in one panel.

-Deepayan

> total_chart <- xyplot(total ~ date,
> xlab=list(label=""),
> ylab=list(label="Total Work")
> )
>
> balance_chart <- xyplot(bal ~ date,
> xlab=list(label=""),
> ylab=list(label="Remaining Work")
> )
>
> index_chart <- xyplot(index ~ date,  col="red", type="b", pch=15)
>
> print(total_chart, split=c(1,1,1,3),   position=c(0, 0, 1, 1),
> newpage=FALSE, more=TRUE)
> print(balance_chart, split=c(1,2,1,3), position=c(0, 0, 1, 1),
> newpage=FALSE, more=TRUE)
> print(index_chart, split=c(1,3,1,3),   position=c(0, 0, 1, 1), newpage=TRUE,
> more=FALSE)
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> 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