[R] Rotating the x-axis labels of a barplot

From: Josh B <joshb41_at_yahoo.com>
Date: Sat, 16 Apr 2011 06:04:56 -0700 (PDT)


Dear listserv,

Here is my latest formatting problem. I would like to rotate the x-axis labels by 45 degrees on a _barplot_. Apparently this is slightly different from the example given in the R FAQ, which is for rotating the x-axis labels on a scatterplot
(
http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-can-I-create-rotated-axis-labels_003f).

I have adapted that code, as best I could, and here is what I have come up with so far:

x <- c(4, 1, 1, 1)
barplot(x, space = 0)
#the "space = 0" argument, above, just reflects my personal preference for having no space between the bars
text(1:4, par("usr")[3] - 0.025, srt = 45, adj = 1, labels = c("< 750", "750-1000", "1000-1250", "> 1250"), xpd = TRUE, font = 2)

The graph this generates is pretty close to what I want, but here's where I'm stuck: How do I move the x-axis labels to the _center_ of each bar? Right now, they line up with the right-side of each bar.

Thank you very much in advance.

Sincerely,



Josh Banta, Ph.D
Center for Genomics and Systems Biology
New York University
100 Washington Square East
New York, NY 10003
Tel: (212) 998-8465
http://plantevolutionaryecology.org

        [[alternative HTML version deleted]]



R-help_at_r-project.org 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. Received on Sat 16 Apr 2011 - 16:20:54 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 17 Apr 2011 - 00:40:30 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive