[R] Change the limits of a plot "a posteriori"
Greg.Snow at imail.org
Tue Dec 6 22:17:29 CET 2011
The zoomplot function in the TeachingDemos package can be used for this (it actually redoes the entire plot, but with new limits). This will generally work for a quick exploration, but for quality plots it is suggested to create the 1st plot with the correct range to begin with.
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
greg.snow at imail.org
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of jcano
> Sent: Thursday, December 01, 2011 11:12 AM
> To: r-help at r-project.org
> Subject: [R] Change the limits of a plot "a posteriori"
> Hi all
> How can I change the limits (xlim or ylim) in a plot that has been
> For example, consider this naive example
> When adding the second curve, it goes off the original limits computed
> by R
> for the first graph, which are roughly, c(0,2.1)
> I know two obvious solutions for this, which are:
> 1) passing a sufficiently large parameter e.g. ylim=c(0,4) to the first
> 2) switch the order in which I plot the curves
> but I guess if there is any way of adjusting the limits of the graphic
> posteriori", once you have a plot with the undesired limits, forcing R
> redraw it with the new limits, but without having to execute again the
> "curve" commands
> Hope I made myself clear
> Best regards and thank you very much in advance
> View this message in context: http://r.789695.n4.nabble.com/Change-the-
> Sent from the R help mailing list archive at Nabble.com.
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help