[R] Understanding padding in lattice

Sebastien Bihorel Sebastien.Bihorel at cognigencorp.com
Tue Apr 28 20:51:07 CEST 2009


Dear R-users,

I am trying to understand what the different padding arguments in 
trellis.par.set are exactly controlling the space around lattice plots. 
I have used the following code as a basis for testing but it did not 
really help me to visualize how the value of each argument changes the 
margins and the plotting area. I guess a better way to visualize the 
effects of these padding items would be to create colored polygons for 
each related "area" of interest... but I would need to know what are 
these areas beforehand!

Any advise on how to improve this code would be greatly appreciated.

Sebastien

#######################
library(lattice)
foo <- 
data.frame(x=rep(seq(10),9),y=rep(seq(10),9),z=rep(0,90),id=rep(seq(9),each=10))
plot1 <- xyplot(y+z~x|id,
                data=foo,
                type=c("p","l"),
                distribute.type = TRUE,
                main="This is a test",
                sub="Subtitle",
                auto.key=T)
trellis.device(pdf, file = "trellis_par_test.pdf",
               paper="letter",
               #family="Courier",
               theme = list(fontsize = list(text = 10, points = 10)))
trellis.par.set(layout.widths =list(left.padding=0,
                                    right.padding=0),
                layout.heights=list(top.padding =1,
                                    main.key.padding =1,
                                    axis.xlab.padding=1,
                                    key.sub.padding  =1,
                                    bottom.padding   =1),
                axis.components=list(top=list(tck=1,  
                                              pad1=1, 
                                              pad2=1), 
                                     right=list(tck=1, 
                                                pad1=1,
                                                pad2=1))) 
print(plot1)
dev.off()
###########################



-- 
*Sebastien Bihorel, PharmD, PhD*
PKPD Scientist
Cognigen Corp
Email: sebastien.bihorel at cognigencorp.com 
<mailto:sebastien.bihorel at cognigencorp.com>
Phone: (716) 633-3463 ext. 323




More information about the R-help mailing list