[R] adjusting x-axis labels
Adrienne Keller
adrienne.keller at umontana.edu
Tue Jul 26 19:33:51 CEST 2011
I am trying to tweak how my categorical x-axis labels are formatted in
my bar graph. Specifically, I would like to a) decrease the spacing
between lines (e.g. spacing between Dialium and guianensis) b) right
justify the text and c) have each species name align with the center
of the corresponding bar graph.
A simplified version of my code thus far is as follows. I am using
RStudio v. .94.84
install.packages('gplots')
library(gplots)
x<-rnorm(9, mean=600, sd=300)
speciesnames<-c("Dialium\nguianensis", "Inga\nalba", "Tachigali
\nversicolor", "Brosimum\nutile", "Caryocar\ncostaricense", "Castilla
\ntunu", "Otoba\nnovagranatensis", "Pourouma\nbicolor", "Socratea
\nexorrhiza")
xvals<-barplot2(x, ylab=expression(plain("Soil acid phosphatase
activity")~(nmol~h^{-1}*g^{-1})), ylim=c(0,1200), cex.axis=0.6)
text(xvals,par("usr")[3]-115, srt=45,adj=c(0.5,0),
labels=speciesnames, cex=.6, xpd=T)
Any suggestions to help solve these problems would be greatly
appreciated. I am new to working with graphics in R.
Thanks,
Adrienne Keller
Graduate Student, College of Forestry
University of Montana
adrienne.keller at umontana.edu
(Phone) 651-485-5822
More information about the R-help
mailing list