Re: [R] How to change min and max of plot axis

From: Marc Schwartz <marc_schwartz_at_comcast.net>
Date: Sat, 21 Jun 2008 10:34:20 -0500

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.
>
> 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?
>
> Thanks

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))

HTH, Marc SChwartz



R-help_at_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. Received on Sat 21 Jun 2008 - 15:38:54 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 21 Jun 2008 - 16:30:48 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive