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

From: Jari Oksanen <jari.oksanen_at_oulu.fi>
Date: Sun, 03 Feb 2008 09:59:26 +0200


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



R-help_at_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. Received on Mon 04 Feb 2008 - 07:20:59 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 04 Feb 2008 - 08:30:10 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive