[R] plot scale

baptiste auguie baptiste.auguie at googlemail.com
Fri Oct 2 11:17:48 CEST 2009


It looks like lattice or ggplot2 might make this easier, but I'm not
entirely sure I understood the problem, short of an example.



2009/10/2 Duncan Murdoch <murdoch at stats.uwo.ca>:
> On 02/10/2009 4:07 AM, Ben Kenward wrote:
>> Hi,
>> Is there a way to set the scale of a plot (i.e. number of axis units
>> per centimeter) when you output it to postscript? If not, how am I
>> supposed to plot graphs with different axis limits to the same scale?
>> They just get resized to fit the paper so that graphs which show a
>> smaller number of axis units end up with a larger scale.
> I don't think there's a simple way to specify the exact relationship, but
> you can do it with some work.
> When you open the postscript device, you can specify the size.  When you do
> a plot, you can specify the size of the margins, so that lets you indirectly
> specify the size of the plot region.  And of course you can specify the axis
> limits.
> So the way I'd do what you want is as follows:  plot the data, use
> par("usr") to extract the axis limits, use par("mai") to extract the margin
> size.  Then calculate the size you want for the particular scaling, and open
> the postscript device with that size, reset par("mai") to the previous
> value, and repeat your plot.
> Duncan Murdoch
> ______________________________________________
> 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.

More information about the R-help mailing list