[R] minimize white space around lattice plot
Sebastian Weber
sebastian.weber at physik.tu-darmstadt.de
Thu Sep 13 09:44:03 CEST 2007
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!
Greetings,
Sebastian Weber
More information about the R-help
mailing list