Hi, how can I scale the x- and y-axis of a "plot" to the same scale? My problem: The following command sequence produces the plot in a square. What I want is the x-axis to be 5 times as wide (measured e.g. in pixels) as the y-axis is long (because y ranges from -1 to 1 and x ranges from 0 to 10). x <- seq( from=0, to=10, by=.1) sinx <- sin(x) plot( x, sinx, type="l") In noth help(plot) and help( par) I couldn't find a solution. What am I missing? Thanks for any hint, till ________________________________________ Mehr Power f?r Ihre eMail - mit den neuen Leistungspaketen bei http://www.epost.de
On Wed, 12 Mar 2003, Till Baumgaertel wrote:> how can I scale the x- and y-axis of a "plot" to the same scale? > > My problem: The following command sequence produces the plot in a square. > What I want is the x-axis to be 5 times as wide (measured e.g. in pixels) > as the y-axis is long (because y ranges from -1 to 1 and x ranges from 0 > to 10).It depends what graphics device you are using. If the plot is in a window on the computer screen, then resizing the window reshapes the plot to whatever aspect ratio you want, interactively, so the aspect ratio is not an issue. For a hardcopy device, such as postscript(), the traditional way to control the aspect ratio is to fill up the rest of the page with margins. For a nice, long narrow plot ... postscript("some.file.name", pointsize=11, horizontal=T) par(mar=c(9.5,3.5,3,2), las=1) plot(x, y, type="p") ... but after printing one test page, I always take a ruler and measure the spacing of the tick marks and calculate how to adjust the margin widths better. Seriously. I use a ruler. It's clunky, but if you care about the graphical scales, that's how you do it, and no complaints. Even the difference between "A4" and "letter" paper sizes would throw off any automated calculation. - tom blackwell - u michigan medical school - ann arbor -
On Wed, 12 Mar 2003, Till Baumgaertel wrote:> Hi, > > how can I scale the x- and y-axis of a "plot" to the same scale? > > My problem: The following command sequence produces the plot in a square. > What I want is the x-axis to be 5 times as wide (measured e.g. in pixels) > as the y-axis is long (because y ranges from -1 to 1 and x ranges from 0 > to 10). > > x <- seq( from=0, to=10, by=.1) > sinx <- sin(x) > plot( x, sinx, type="l") > > In noth help(plot) and help( par) I couldn't find a solution. What am I > missing?That's right - but the "see also" in ?plot gets you to ?plot.default, which in turn gets you to ?plot.window: asp: numeric, giving the aspect ratio y/x. where asp=1 will force plot to impose equal scales on the axes, and is passed through by plot(). Roger Bivand> > Thanks for any hint, > till > > > > > ________________________________________ > Mehr Power f?r Ihre eMail - mit den neuen Leistungspaketen bei http://www.epost.de > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help >-- Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Breiviksveien 40, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93 e-mail: Roger.Bivand at nhh.no
On Tuesday 11 March 2003 05:00 pm, Till Baumgaertel wrote:> Hi, > > how can I scale the x- and y-axis of a "plot" to the same scale? > > My problem: The following command sequence produces the plot in a square. > What I want is the x-axis to be 5 times as wide (measured e.g. in pixels) > as the y-axis is long (because y ranges from -1 to 1 and x ranges from 0 > to 10). > > x <- seq( from=0, to=10, by=.1) > sinx <- sin(x) > plot( x, sinx, type="l") > > In noth help(plot) and help( par) I couldn't find a solution. What am I > missing?See asp in help(plot.default), though this doesn't seem to change the aspect ratio of the box (which you can probably do with par). An alternative is to use xyplot in the lattice library: xyplot(y ~ x, type = "l", aspect = 1/5) (This will make the aspect ratio of the bounding box 1/5 and not the actual scales, but you can control that by further specifying xlim and ylim.) Hope that helps, Deepayan