On 21/06/2008 11: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.

x<-rnorm(20)
Y<-x+rnorm(20,0,.1)
plot(y,x)
par("usr")

# 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

usr<-par("usr")
par(usr=c(usr[1:2],-5,5))
plot(y,x)

# it does not take the -5 to 5???

Is there any way to set the axis values?

plot() will set up the coordinate system. You can use the ylim argument to set the limits, e.g.

plot(y, x, ylim=c(-5,5))

(This is a little confusing, since the y variable ends up on the x axis and vice versa: the convention in R is plot(x, y).)

Duncan Murdoch

______________________________________________
R-help@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.

Reply via email to