[R] R-Graphics: Scaling axis

Deepayan Sarkar deepayan at stat.wisc.edu
Wed Mar 12 08:45:50 CET 2003

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,


More information about the R-help mailing list