[R] convert lines to inches

Peter Dalgaard p.dalgaard at biostat.ku.dk
Sun Oct 19 15:13:35 CEST 2008


Thomas Steiner wrote:
> Ok, thanks Peter, I try to be more accurate:
> 
> pdf("test.pdf",width=(20+2+4)/2.54,height=(10+3+1)/2.54)
> x=seq(0,pi,length=100)
> par( mai=c(2,3,4,1)/2.54 )
> plot(x,cos(x),type="l",xlim=c(0,3),ylim=c(-1.2,1.2),xaxs="i",yaxs="i",asp=1)
> conv=par("mar")/par("mai")
> box("figure", col="darkblue")
> dev.off()
> 
> Then figure has as expected the size 26x14cm.
> But the size of the *Plot Area* is not as expected 20x10cm, but
> 22x8cm, although I chose the margins in inches as 2 and 4 cm below and
> above (=26-(2+4)). Probably I confuse something with lines and inches.
> I'd like to have a plot area of 20x10cm and around it a (2,3,4,1)cm
> margin.
> Thanks for hints and have a nice Sunday,
> Thomas

Ah, now I see it. Notice that the _order_ in par("mai") follows the 
conventions for side=n; that is, bottom, left, top, right. So you want 
either mai=c(3,2,1,4) or width=20+3+1,height=10+2+4.

-- 
    O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
   c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
  (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)              FAX: (+45) 35327907



More information about the R-help mailing list