[R] plot with the axes at xlim and ylim

ripley@stats.ox.ac.uk ripley at stats.ox.ac.uk
Tue Mar 19 12:15:40 CET 2002


On 19 Mar 2002, Arnold Kester wrote:

> I'd like to make a plot with the axes drawn at the values of xlim and
> ylim. The default plot draws the axes slightly outside these values. I
> have been experimenting with the par(mgp) setting, but specifying
> par(mgp=c(2,0,-1)) gives me
>
> "invalid value specified for graphics parameter "mgp".".
>
> A more complicated mathod that almost seems to work is doing the plot
> with "axes=F" and then adding the axes with "axis" statements:
>
> xlim <- c(0,10)
> ylim <- c(0,11)
> plot(c(1:9),c(1:9),axes=F,xlim=xlim,ylim=ylim)
> axis(1,pos=ylim[1])
> axis(2,pos=xlim[1])
> axis(3,pos=ylim[2],labels=F)
> axis(4,pos=xlim[2],labels=F)
>
> The problem here is that the vertical axes are not long enough.
>
> Is there an easier way to get what I want?

par(xaxs="i", yaxs="i")


-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list