[R] Reversing x-axis

Ross Ihaka ihaka at stat.auckland.ac.nz
Fri Dec 8 01:29:25 CET 2000

On Thu, Dec 07, 2000 at 04:52:16PM -0500, ben at zoo.ufl.edu wrote:
> http://www.ens.gu.edu.au/robertk/R/devel/00b/0206.html
> http://www.ens.gu.edu.au/robertk/R/devel/00a/0419.html
>   At this time, you have to do something like
> x <- rnorm(100)
> y <- rnorm(100)
> plot(max(x)-x,max(y)-y,axes=FALSE)
> xlabvals <- pretty(x,5)
> ylabvals <- pretty(y,5)
> axis(side=1,at=max(x)-xlabvals,labels=xlabvals)
> axis(side=2,at=max(y)-ylabvals,labels=ylabvals)
>   I think it's time to put this one in the FAQ ... (although, again, I
> don't know if I would have found it just searching the archives if I
> hadn't remembered that it was there in the first place).

If I understand this right, you want to reverse the direction of the axes.
This is a bug which seems to have crept in at some point and hung around
rather longer than it should have.  In the development version you can
now do the following:

	x <- rnorm(100)
	y <- rnorm(100)
	plot(x, y, xlim=rev(range(x)), ylim=rev(range(y)))

and get the result you expect.

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