[R] convert lines to inches

Thomas Steiner finbref.2006 at gmail.com
Sun Oct 19 10:39:38 CEST 2008


Hi,

how can I convert the unit "lines" of par("mar") into inches?
par("mai") could help, but does not (see code below).

I want to plot a curve in a predefined size in pdf (I add some margin
space to the plot width&height, everything is in cm):
pdf("test.pdf",width=(20+2+4)/2.54,height=(10+3+1)/2.54)
plot(10:30, 9*cos(10:30),type="l",xlim=c(10,30),ylim=c(-10,15),xaxs="i",yaxs="i",asp=1)
#par(mar=c(0,0,0,0))
par(mai=c(2,3,4,1)/2.54)
box("figure", col="darkblue")
dev.off()

The size of the darkblue box is fine, but I cannot yet control the
size of the plot area (although
http://research.stowers-institute.org/efg/R/Graphics/Basics/mar-oma/index.htm
helped me a lot). And seeting the mar to zero (#) works in a R figure,
but not in a pdf. Why?

I already asked ("draw a 5cm x 3cm rectangle") a related question
three days ago, but I was unable to get a more complicated example in
the grid package (solution there) running.

Thanks for giving hints,
Thomas



More information about the R-help mailing list