# plot scale

6 messages
Open this post in threaded view
|
Report Content as Inappropriate

## plot scale

 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. Cheers, Ben -- Dr. Ben Kenward Department of Psychology, Uppsala University, Sweden http://www.benkenward.com______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|
Report Content as Inappropriate

## Re: plot scale

 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 ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|
Report Content as Inappropriate

## Re: plot scale

 On Fri, Oct 2, 2009 at 11:10 AM, Duncan Murdoch <[hidden email]> wrote: > I don't think there's a simple way to specify the exact relationship, but > you can do it with some work. Thanks Duncan. That's what I was beginning to suspect, nice to have confirmation, even if it will mean a bit of work. Ben -- Dr. Ben Kenward Department of Psychology, Uppsala University, Sweden http://www.benkenward.com______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|
Report Content as Inappropriate

## Re: plot scale

 In reply to this post by Duncan Murdoch Hi, It looks like lattice or ggplot2 might make this easier, but I'm not entirely sure I understood the problem, short of an example. Best, baptiste 2009/10/2 Duncan Murdoch <[hidden email]>: > 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 > > ______________________________________________ > [hidden email] 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. > ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|
Report Content as Inappropriate

## Re: plot scale

 In reply to this post by amorphia > > 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. > > Cheers, > > Ben > If I understand you correctly, you want the units on each axis to be physically represented equally on the same scale.  If this is right, try using the lattice package (xyplot, etc.) with aspect="iso". Lattice lets you adjust the aspect ratio of the plot to whatever you like and constrains the dimensions of the plot accordingly.  Base graphics also allow for control of the aspect ratio using "asp=", but extend the limits of the plot to fill whatever region you are plotting in. ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.