Re: [R] Help on direction of axis in R needed

From: Gavin Simpson <>
Date: Wed 11 Oct 2006 - 09:44:17 GMT

On Wed, 2006-10-11 at 02:27 -0700, Silvia Lipski wrote:
> Hi!
> I'd like to plot things with axes going from the
> highest to the lowest value, so that e.g. high values
> on the xaxis are plotted to the left and low values to
> the right.
> Could anyone tell me how this is done? I couldn't find
> anything in the documentation.
> Thanks a lot!
> Silli

Look at ?plot.default and in particular argument 'xlim', which take two settings, effectively from and to, (e.g. xlim = c(100, 1) will give x axis drawn from 100 on left to 1 on right)

plot(1:100, 1:100, xlim = c(175, 0))

Where we don't know the range of data explicitly, we can use for example range() to get the min and max of the data and then rev() to reverse these, as the example below shows:

xdat <- rnorm(100)
ydat <- runif(100)
plot(ydat ~ xdat, xlim = rev(range(xdat)))

The See Also section of ?plot would have pointed you to ?plot.default...


 Gavin Simpson                 [t] +44 (0)20 7679 0522
 ECRC & ENSIS, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building,             [e]
 Gower Street, London          [w]
 UK. WC1E 6BT.                 [w]

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Wed Oct 11 19:56:50 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 11 Oct 2006 - 10:30:09 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.