[R] Help on direction of axis in R needed
Gavin Simpson
gavin.simpson at ucl.ac.uk
Wed Oct 11 11:44:17 CEST 2006
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...
HTH
G
--
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Gavin Simpson [t] +44 (0)20 7679 0522
ECRC & ENSIS, UCL Geography, [f] +44 (0)20 7679 0565
Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/
UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
More information about the R-help
mailing list