[R] png() and pdf() alignment problems

Jari Oksanen jari.oksanen at oulu.fi
Sun Feb 3 08:59:26 CET 2008


Dear Roland Kaiser,

I think there may different pixel-to-point scaling in different  
devices. This scaling seems not only to vary with the device but even  
with your physical screen. This is what happens with my current box  
(MacBook):

 > quartz()
 > par("mar")/par("mai")
[1] 6 6 6 6
 > par("cra")
[1]  6 12
 > png()
 > par("mar")/par("mai")
[1] 4.686347 4.686347 4.686347 4.686347
 > par("cra")
[1] 13 16
 > dev.off()
 > pdf()
 > par("mar")/par("mai")
[1] 5 5 5 5
 > par("cra")
[1] 10.8 14.4
 > x11()
 > par("mar")/par("mai")
[1] 4.686347 4.686347 4.686347 4.686347
 > par("cra")
[1] 13 16

The quotient gives the par margin line height in inches, par("cra")  
the dimensions of the characters in "rasters" (which may be close to  
size in points, but may differ a lot in some screens). For your  
alignment, I think you want to make margin proportions equal in two  
devices, and you must scale so figs so instead of using physically  
equal dimensions. The mar/mai ratio or cra does not change with  
device width & height, so you must change those so that for fig looks  
like it should.

I have no ideas if this works, but I think this still is your problem...

Greetings to the Moderator,

Jari Oksanen

Cheers, Jari Oksanen



More information about the R-help mailing list