Hi All, I need some help in putting text in a stacked barplot. The barplot is filled with 5 levels and now I would like to put text to each level in the stacked barplot. However, it seems that the code that I am using is not placing the text at the correct hight (centered at each fill) in the barplot. Any suggestions to improve the code to make it work? barchart(FREQ ~ VISIT |which*as.factor(TRTN), data = stuffa,par.strip.text list(cex = 0.35), groups = RES, xlab="Visit",ylab="Frequency", layout = c(4,2), par.settings=list(superpose.polygon=list(col=colors()[c(636,96,256,92,27,376)])), stack = T, auto.key = list(points = FALSE, rectangles = TRUE, space = "top"), scales = list(x = list(alternating=c(1,1),tck=c(1,0),abbreviate = TRUE, minlength = 5, rot = 0),y=list(alternating=c(1,1),tck=c(1,0))), panel = function(y,x,...){ panel.grid(h = -1, v = 0, col = "gray", lty = 3,lwd=1) panel.barchart(x,y,...) panel.text(x,y,label = round(y,1),cex=0.48) } ) Kind regards, Ashraf Yassen [[alternative HTML version deleted]]
Please post some data (fake data is fine) for stuffa. The example doesn't execute as is. Rich On Mon, Nov 8, 2010 at 10:27 AM, Ashraf Yassen <ashraf.yassen@gmail.com>wrote:> Hi All, > > I need some help in putting text in a stacked barplot. The barplot is > filled > with 5 levels and now I would like to put text to each level in the stacked > barplot. However, it seems that the code that I am using is not placing the > text at the correct hight (centered at each fill) in the barplot. Any > suggestions to improve the code to make it work? > > barchart(FREQ ~ VISIT |which*as.factor(TRTN), data = stuffa,par.strip.text > > list(cex = 0.35), > groups = RES, xlab="Visit",ylab="Frequency", > layout = c(4,2), > > par.settings=list(superpose.polygon=list(col=colors()[c(636,96,256,92,27,376)])), > stack = T, > auto.key = list(points = FALSE, rectangles = TRUE, > space = "top"), > scales = list(x = list(alternating=c(1,1),tck=c(1,0),abbreviate = TRUE, > minlength > = 5, rot = 0),y=list(alternating=c(1,1),tck=c(1,0))), > panel = function(y,x,...){ > panel.grid(h = -1, v = 0, col = "gray", lty = 3,lwd=1) > panel.barchart(x,y,...) > panel.text(x,y,label = round(y,1),cex=0.48) > } > ) > > > > Kind regards, > Ashraf Yassen > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > R-project.org/posting-guide.html<r-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]