[R] par code help

Adrienne Keller adrienne.keller at gmail.com
Tue Jun 21 22:29:10 CEST 2011


I am making a barplot using barplot2 from gplots where each bar  
represents a specific tree species. I have formatted the species names  
on the x-axis so that the genus name is above the species name and  
have then rotated the labels 45 degrees to save room. This is my code:

 >columncolor<-c("grey20", "grey20", "grey20", "grey70", "grey70",  
"grey70", "grey70", "grey70", "grey70")
 >speciesnames<-c("Dialium\nguianensis", "Inga\nalba", "Tachigali 
\nversicolor", "Brosimum\nutile", "Caryocar\ncostaricense", "Castilla 
\ntunu", "Otoba\nnovagranatensis", "Pourouma\nbicolor", "Socratea 
\nexorrhiza")
 >barplot2(meanapAprilactivity, names.arg=speciesnames,  
col=columncolor, xlab="Species", ylab="Soil acid phosphatase activity  
(nmol/h/g)", ylim=c(0,1000), plot.ci=T, ci.l=apAprilminusordered,  
ci.u=apAprilplusordered, cex.lab=1.5)#FinalGraphs>aPApril_Genus.pdf
 >xvals<-barplot2(meanapAprilactivity, col=columncolor,  
xlab="Species", ylab="Soil acid phosphatase activity (nmol/h/g)",  
ylim=c(0,1000), plot.ci=T, ci.l=apAprilminusordered,  
ci.u=apAprilplusordered, cex.lab=1.5)#FinalGraphs>aPApril_Genus.pdf
 >text(xvals,par("usr")[3]-1, srt=45, adj=0.5,labels=speciesnames,  
xpd=T)

I have a few problems/questions:

1) The middle of the species names are placed at the bottom of the  
bar, such that half of the label is in the figure.

2) There is too much of a space between the genus and species name  
(e.g. between Dialium and guianensis for my first species)

3) Do I use cex.axis to change the font size of the labels and cex.lab  
to change the font size of xlab and ylab?

I don't understand par() well enough to know what to change. I figured  
changing the numbers after "usr" might help but I don't understand  
what these numbers refer to and guess and check hasn't gotten me  
anywhere.

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