[R] About error bars on barplots
    lily li 
    chocold12 at gmail.com
       
    Sun Jun 18 02:10:55 CEST 2017
    
    
  
Hi R users,
I have a question about adding uncertainty bars to stacked bar plots.
DF:
  year   A   B   C   Amin  Amax  Bmin  Bmax  Cmin  Cmax
 2009  40  45  15   30      61       23       56      14       17
 2010  36  41  23   26      54       22       51      22       24
I use the code below:
DF.refm = melt(subset(DF[,c(1:4)]),id.vars='year',variable_name='Legend')
fig1 = ggplot(data=DF.refm, aes(x=year,y=value,fill=Legend))+
  geom_bar(stat='identity',size=.5)+ theme_bw()+ xlab('Year')+
ylab('Percent (%)')
print(fig1)
But I don't know how to change it a little bit. For example, how to add the
error bars on the plot, as is shown in the figure below? The error bar for
variable A ranges from Amin to Amax, the same applies to variables B and C.
Thanks for your help.
    
    
More information about the R-help
mailing list