[R] Understanding padding in lattice

Paul Murrell p.murrell at auckland.ac.nz
Thu Apr 30 02:34:46 CEST 2009


Hi

In the development version of R, there is a new showViewport() function
that might help with debugging this sort of thing.  Try ...

showViewport()

... or possibly ...

showViewport(newpage=TRUE)

... just after drawing your plot.

Paul


Deepayan Sarkar wrote:
> On Tue, Apr 28, 2009 at 11:51 AM, Sebastien Bihorel
> <Sebastien.Bihorel at cognigencorp.com> wrote:
>> 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!
> 
> You can retrieve the undelying grid layout and show it using
> 
> library(grid)
> grid.show.layout(lattice:::lattice.getStatus("layout.details")$page.layout)
> 
> which is close to what you are describing. Otherwise, there's no easy
> way to insert polygons in these areas that I know of.
> 
> You could try setting negative padding values to see what they do.
> 
> -Deepayan
> 
>> 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
>>
>> ______________________________________________
>> 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.
>>
> 
> ______________________________________________
> 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.

-- 
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
paul at stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/




More information about the R-help mailing list