[R] labelling a stacked barchart (lattice)
M/K Zodet
mkzodet at comcast.net
Thu Aug 4 03:01:37 CEST 2011
All:
Below is my code for creating a basic horizontal, stacked barchart. I'd like to label the plot in two ways: 1) place the x values in each piece and 2) place the y values above each piece (angled). I'm currently using lattice, but I'm open to suggestions using ggplot2.
Questions:
1. Can this be done?...I assume yes. So, what are the best options/functions for doing this.
2. Is there a way to alter the transparency of the bar fill with the brewer palette? I know I can alter this w/ heat.~, topo.~, cm.colors, etc.
Thanks in advance.
Marc
Using R for Mac OS X GUI 1.40-devel Leopard build 64-bit
dta <- data.frame(x=c(46.0, 14.7, 16.4, 15.8, 7.0), y=c("Back", "Neck", "Extrem", "MuscSkel", "Oth"))
dta
barchart(data=dta, ~x, group=y, stack=T, col=sort(brewer.pal(7,"Purples")),
xlab="Percent", box.width=.5, scales=list(tick.number=10))
More information about the R-help
mailing list