Re: [R] trellis margin sizes in absolute units

2012-07-12 Thread Deepayan Sarkar
On Thu, Jul 12, 2012 at 9:39 PM, Martin Ivanov  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.


Re: [R] trellis margin sizes in absolute units

2012-07-12 Thread Bert Gunter
It is not clear to me what you want in the lattice context, but perhaps

?print.trellis

may be relevant.

Note that  "inner" and "outer" margins are not directly translatable in
lattice, as there are multiple levels of plots involved, all determined by
viewport contexts. Ergo my confusion about what you're after.

Cheers,
Bert

On Thu, Jul 12, 2012 at 9:09 AM, Martin Ivanov  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?
>
> Any suggestions will be appreciated.
>
> Regards,
> Martin
>
>
> -
> Ãðàæäàíñêà îòãîâîðíîñò – Öåíèòå íà êîìïàíèèòå
>
> http://www.sdi.bg/onlineInsurance/?utm_source=gbg&utm_medium=txtLink&utm_content=home
>
> __
> 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.
>



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

[[alternative HTML version deleted]]

__
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.


[R] trellis margin sizes in absolute units

2012-07-12 Thread Martin Ivanov
 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?

Any suggestions will be appreciated.

Regards,
Martin


-
Гражданска отговорност – Цените на компаниите
http://www.sdi.bg/onlineInsurance/?utm_source=gbg&utm_medium=txtLink&utm_content=home

__
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.