Skip to content

Spacing and margins in lattice...

3 messages · Jamieson Cobleigh, Sundar Dorai-Raj

#
Similar to my last question, I want to tighten up the spacing and
margins in a plot I am doing with lattice.

Here are the commands I'm using:

data <- data.frame(x=c(1:3, 1:3), y=c(1:3, 1:3*2),
cat=c("foo","foo","foo","bar", "bar","bar"))

xyplot(panel=panel.superpose, y~x, data=data, groups=cat, type="b",
scales=list(tck=c(2,0), axs="r", cex=c(1,0)))

I know that par(mar=c(2,2,1,1)) would do what I want with plot.  Is
there something similar for xyplot/lattice that can reduce the size of
the margins of the plot?

Thanks!

Jamie
#
Jamieson Cobleigh wrote:
Hi, Jamie,

Will the following work for you?

library(lattice)
data <- data.frame(x = c(1:3, 1:3), y = c(1:3, 1:3*2),
                    cat = c("foo","foo","foo","bar", "bar","bar"))

trellis.par.set(theme = col.whitebg())

lw <- list(left.padding = list(x = 0, units = "inches"))
lw$right.padding <- list(x = -0.1, units = "inches")
lh <- list(bottom.padding = list(x = 0, units = "inches"))
lh$top.padding <- list(x = -0.2, units = "inches")

lattice.options(layout.widths = lw, layout.heights = lh)
xyplot(y ~ x, data, groups = cat, type="b")

HTH,

--sundar
#
That did the trick.

Thanks!

Jamie
On 9/1/05, Sundar Dorai-Raj <sundar.dorai-raj at pdf.com> wrote: