Re: [R] Plotting with exact axis limits

From: Duncan Murdoch <murdoch_at_stats.uwo.ca>
Date: Mon, 14 Apr 2008 20:09:53 -0400

On 14/04/2008 6:56 PM, Enrico Rossi wrote:
> Hello,
>
> If I make a plot, say something simple like
>
> plot( runif(100) )
>
> then the origin (0,0) is not at the bottom-left corner of the box
> surrounding the plot. The axis limits are "padded" slightly. This is
> ordinarily a good feature, because it makes plots look better. But now I
> would like to make a plot with the origin exactly on the bottom left.
> Through trial and error, I have discovered that this padding is
> approximately 3.8% of the axis length. That is,
>
> plot( runif(100), ylim=c(.038,1), xlim=c(3.8,100))
>
> gives the desired result. However, this seems like a rather inelegant hack.
> Is there a "correct" way to do this?

plot(runif(100), yaxs='i', xaxs='i', ylim=c(0,1), xlim=c(0, 100))

is the "correct" way. yaxs and xaxs are documented in ?par.

The only problem with this is that it may be too tight at the upper limits, because you can't ask to expand at the top but not at the bottom.

Duncan Murdoch



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 Tue 15 Apr 2008 - 02:38:13 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 Tue 15 Apr 2008 - 05:30:27 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