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. 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]]
David Winsemius
2009-Sep-19 16:50 UTC
[R] reducing space between charts in lattice graphics
The Lattice book shows different uses of the layout and between parameters in the early examples in chapter 2. Why not go to the book's website and take a look? -- David. On Sep 19, 2009, at 12:42 PM, Larry White 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. > > 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.David Winsemius, MD Heritage Laboratories West Hartford, CT
Gabor Grothendieck
2009-Sep-19 16:55 UTC
[R] reducing space between charts in lattice graphics
xyplot.zoo does that by default. library(lattice) library(zoo) z <- zoo(cbind(1:4, 2:5, 3:6)) xyplot(z, type = "l") On Sat, Sep 19, 2009 at 12:42 PM, 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. > > 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. >
Deepayan Sarkar
2009-Sep-30 06:35 UTC
[R] reducing space between charts in lattice graphics
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. >