[R] minimize white space around lattice plot

Deepayan Sarkar deepayan.sarkar at gmail.com
Thu Sep 13 23:32:09 CEST 2007


On 9/13/07, Sebastian Weber <sebastian.weber at physik.tu-darmstadt.de> wrote:
> Dear list,
>
> I'm trying to produce a plot via xyplot with minimal sourounding white
> space. However, I cannot find the options in xyplot, ps.options or
> wherever which prevents lattice from drawing quite some white space
> around my plot. However, this is quite a problem for me as I want to
> produce an inset plot inside another lattice-plot. I'm using the panel
> function to open a viewport and print the inset plot within the actual
> plot. The problem now is, that there is lots of sourounding white space
> around my inner plot. Here is an example:
>
> panel.inset <- function(...,
>                         inset,
>                         drawRect=TRUE,
>                         ixpos=unit(0, "mm"), iypos=unit(1, "npc"),
>                         ijust=c("left","top"),
>                         iwidth=unit(0.7, "npc"), iheight=unit(0.5,
> "npc")) {
>   ## open our viewport ...
>   pushViewport(viewport(x=ixpos, y=iypos, width=iwidth, height=iheight,
> just=ijust, name="inset"))
>
>   if(drawRect)
>     grid.rect(gp=gpar(lwd=1,col="black"))
>
>   ## ... and place the other plot inside there
>   print(inset, newpage=FALSE, prefix="insetPlot")
>
>   upViewport()
>
>   ## draw the actual plot
>   panel.xyplot(...)
>
>   ## why is this neccessary?? Otherwise I get no lines for the axis ...
>   grid.rect(gp=gpar())
> }
>
> x<-0:10
> y<-x^4
>
>
> insetPlot <- xyplot(y ~ x, scales=list(log=T), main=NULL, aspect="fill")
> xyplot(y ~ x, panel="panel.inset", inset=insetPlot)
>
> Thank you very much for any input!

See

str(trellis.par.get("layout.widths"))
str(trellis.par.get("layout.heights"))
?trellis.par.set
?xyplot (the entry for 'par.settings')

-Deepayan



More information about the R-help mailing list