On Thu, Jul 12, 2012 at 9:39 PM, Martin Ivanov <tra...@abv.bg> wrote: > Dear R users, > > I have a lot of experience with traditional R graphics, but I decided to turn > to trellis as > it was recommended for spatial graphs by the sp package. In traditional R > graphics > I always first set the size of the device region absolute units (e.g. mm) > and then I > firmly fix the inner margins with mai and the outer margins with oma also in > absolute units. > What is left from the device region is for the plot region. That is my > general idea. > > My question is, is it possible to achieve that full control with trellis > graphics? I have tried > with the *.paddings parameters, but it seems to me that the margins are still > larger than I have set them. > Here is my example code: (mp is a SpatialPixelsDataFrame) > > xlim <- c(.96*bbox(mp)[1, 1], 1.02*bbox(mp)[1, 2]); > ylim <- c(.992*bbox(mp)[2, 1], 1.005*bbox(mp)[2, 2]); > b <- 1; t <- 2; # b, t : should be bottom and top figure margins > l <- 1; r <- 6; # l, r : should be left and right figure margins > asp <- mapasp(data=mp, xlim=xlim, ylim=ylim); > # I have set the width of the device region as w millimetres and here I > calculate > # its height, taking care of the aspect ratio > h <- b + t + asp*(w - (l + r)); > > postscript(output, onefile=FALSE, paper="special", width=w/25.4, > height=h/25.4, horizontal=FALSE, fonts=c("Times"), print.it=FALSE, > colormodel="rgb", pointsize=12); > > # here I set all the possible paddings to make sure that all other margins > are 0: > trellis.par.set(layout.widths=list(left.padding=l, right.padding=r, > key.ylab.padding = 0, > ylab.axis.padding = 0, axis.key.padding = 0, units="mm"), > layout.heights=list(bottom.padding=b, top.padding=t, main.key.padding = 0, > key.axis.padding = 0, axis.xlab.padding = 0, > xlab.key.padding = 0, key.sub.padding = 0, units="mm"), > axis.components=list(bottom=list(pad1=.8), left=list(pad1=.8))); > > But still, the resulting margins are larger than I expect and to achieve the > desired effect I have to set some parameters to negative numbers. So I guess > there are some other graphical parameters that come into play, about which I > do not know. > Which margins are these *.padding parameters controlling: the outer (device) > or the inner (figure) margins?
The 'par.settings' are only multipliers for the defaults, and you want to change the original defaults. For example, the left margin is given by > lattice.getOption("layout.widths")$left.padding $x [1] 0.5 $units [1] "char" which you want to change to, say, list(x = 1, units = "mm"). See ?lattice.options on how to do that (and also the 'lattice.options' entry in ?xyplot). You might have better luck with the development version at https://r-forge.r-project.org/R/?group_id=638 as it has some related bugfixes and documentation improvements. -Deepayan ______________________________________________ R-help@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.