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
Silvia Lipski <sillispiral at yahoo.com> writes:> 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! > SilliJust set the xlim=c(10,0) (or maybe rev(range(x)) or so). -- O__ ---- Peter Dalgaard ?ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
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! > SilliLook 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 %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
> I'd like to plot things with axes going from the > highest to the lowest valueYou can use the xlim and ylim parameters of the plot function. E.g: x = 1:100 plot(x, x^2) # normal plot(x, x^2, xlim=c(100,0)) # reversed x axis cu Philipp -- Dr. Philipp Pagel Tel. +49-8161-71 2131 Dept. of Genome Oriented Bioinformatics Fax. +49-8161-71 2186 Technical University of Munich Science Center Weihenstephan 85350 Freising, Germany and Institute for Bioinformatics / MIPS Tel. +49-89-3187 3675 GSF - National Research Center Fax. +49-89-3187 3585 for Environment and Health Ingolst?dter Landstrasse 1 85764 Neuherberg, Germany http://mips.gsf.de/staff/pagel
Hi something like that? y<-1:10 x<-11:20 plot(x,y) plot(x[10:1],y) # reverse x HTH Petr On 11 Oct 2006 at 2:27, Silvia Lipski wrote: Date sent: Wed, 11 Oct 2006 02:27:34 -0700 (PDT) From: Silvia Lipski <sillispiral at yahoo.com> To: r-help at stat.math.ethz.ch Subject: [R] Help on direction of axis in R needed> 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 > > ______________________________________________ > R-help at stat.math.ethz.ch 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.Petr Pikal petr.pikal at precheza.cz