Skip to content
Prev 317787 / 398506 Next

How to label percentage values inside stacked bar plot using R-base

On 02/18/2013 06:05 PM, nay-nancy Laiser wrote:
Hi Nay,
You can label the plot you have done above like this:

mydata<-matrix(c(100,200,300,400,500,
  68.33333,53.33333,70,70,61.66667,
  31.66667,46.66667,30,30,38.33333),ncol=3)
colnames(mydata)<-c("Village","Male","Female")
xpos<-barplot(mydata,col=c("yellow","green"))
library(plotrix)
barlabels(rep(xpos,each=5),
  apply(mydata,2,cumsum)-mydata/2,
  labels=mydata,prop=1,cex=0.7)

However, the plot is pretty redundant and you might want to consider 
other ways of presenting the data.

Jim