[R] How to change min and max of plot axis
marc_schwartz at comcast.net
Sat Jun 21 17:34:20 CEST 2008
on 06/21/2008 10:25 AM Luis Orlindo Tedeschi wrote:
> All; this might be an easy question but I cannot make it work. I would
> like to set the min and max of the y axis of a plot. I know I have to
> use par("usr"), but after I do the plot() the axis values get changed.
> # let's say I have -2.8 1.15 -2.8 1.16 for par("usr")
> # let's say I need to change the Y-axis to be -5 to 5
> # it does not take the -5 to 5???
> Is there any way to set the axis values?
In ?par, take note of the 'ylim' and 'xlim' parameters, which are also
noted in ?plot.default.
x <- rnorm(20)
y <- x + rnorm(20, 0, .1)
plot(x, y, ylim = c(-5, 5))
More information about the R-help