a<-c(1:10) plot(a,ylim=c(10,1)) On Tue, 2005-22-11 at 15:03 -0500, Anthony Pitts wrote:> Hello all, > > Does anyone know how to make R graph the x-axis in descending order? I am all > set in creating a vertical bar chart using either the plot or the xychart (in > lattice), but I need the x-axis in descending order. I have tried resorting > the data but apparently R automatically graphs the x-axis in ascending order. > I have multiplied the data used for the x-axis by -1 and this works but now > the tick-mark labels are negative. So does anyone know how to 1) make R graph > the x-axis in descending order or 2) change the tick labels so I can get rid > of the negative signs? > > Thanks in advance for your help > > Tony > > > > > [[alternative HTML version deleted]] > > ______________________________________________ > 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 >
Hello all, Does anyone know how to make R graph the x-axis in descending order? I am all set in creating a vertical bar chart using either the plot or the xychart (in lattice), but I need the x-axis in descending order. I have tried resorting the data but apparently R automatically graphs the x-axis in ascending order. I have multiplied the data used for the x-axis by -1 and this works but now the tick-mark labels are negative. So does anyone know how to 1) make R graph the x-axis in descending order or 2) change the tick labels so I can get rid of the negative signs? Thanks in advance for your help Tony [[alternative HTML version deleted]]
On 11/22/05, Anthony Pitts <apitts at burstmedia.com> wrote:> Hello all, > > Does anyone know how to make R graph the x-axis in descending order? I am > all set in creating a vertical bar chart using either the plot or the xychart > (in lattice),There's no such function, I presume you mean barchart.> but I need the x-axis in descending order.I'm a bit confused, because a vertical barchart would normally have a categorical variable on the x-axis, yet you talk of numeric labels for them. Please provide a reproducible example. For numeric axes specifying a reversed xlim (e.g. xlim = c(10, 0) ) should work. -Deepayan> I have tried resorting > the data but apparently R automatically graphs the x-axis in ascending > order. > I have multiplied the data used for the x-axis by -1 and this works but now > the tick-mark labels are negative. So does anyone know how to 1) make R > graph > the x-axis in descending order or 2) change the tick labels so I can get > rid > of the negative signs? > > Thanks in advance for your help > > Tony
Dear Anthony, You can use xlim in plot() to reverse the x-axis. For example, x <- 1:10 y <- x plot(x, y, xlim=rev(range(x))) (I'm pretty sure, by the way, that this question has been asked before.) I hope this helps, John -------------------------------- John Fox Department of Sociology McMaster University Hamilton, Ontario Canada L8S 4M4 905-525-9140x23604 http://socserv.mcmaster.ca/jfox --------------------------------> -----Original Message----- > From: r-help-bounces at stat.math.ethz.ch > [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Anthony Pitts > Sent: Tuesday, November 22, 2005 3:04 PM > To: r-help at stat.math.ethz.ch > Subject: [R] graphing help > > Hello all, > > Does anyone know how to make R graph the x-axis in descending > order? I am all set in creating a vertical bar chart using > either the plot or the xychart (in lattice), but I need the > x-axis in descending order. I have tried resorting the data > but apparently R automatically graphs the x-axis in ascending order. > I have multiplied the data used for the x-axis by -1 and this > works but now the tick-mark labels are negative. So does > anyone know how to 1) make R graph the x-axis in descending > order or 2) change the tick labels so I can get rid of the > negative signs? > > Thanks in advance for your help > > Tony >