0

I'm trying to plot a grouped bar chart with ggplot2 using this R code # Cross graph Satisfaction & Procédure de gestion des réclamations library(ggplot2) library(scales) #q13

as.data.frame(table(data$q13_a))
as.data.frame(table(data$q13_b))
as.data.frame(table(data$q13_6))


blank_theme =
theme( axis.ticks = element_blank(),
     plot.title=element_text(size=14, face="bold.italic")
    )
 df1 = data.frame(Satisfaction=rep(c("Très insatisfait",
 "Insatisfait","Moyennement satisfait","Satisfait","Très satisfait"),3),
 Procédure=rep(c("La prise \n en charge du réclamant","Délai 
 du traitement \n de la réclamation","La qualité de la réponse \n 
 apportée à la réclamation"),each=5),
 Count=c(8,7,17,21,3,14,7,16,15,4,14,8,13,18,3),
 Pourcentage=round(c(8,7,17,21,3,14,7,16,15,4,14,8,13,18,3)
 /sum(c(8,7,17,21,3,14,7,16,15,4,14,8,13,18,3)),4)*100)
 df1$Procédure = as.factor(as.vector(df1$Procédure))
 df1$Satisfaction=as.factor(df1$Satisfaction)
 ggplot(data=df1, aes(Procédure,Pourcentage, fill=Satisfaction))+
 geom_bar(stat="identity",position=position_dodge(0.8)
 ,width=0.8,color='black')+
 geom_text(data=df1,aes(label=paste(round(df1$Pourcentage,1),"%\n")),
  y=df1$Pourcentage+2, hjust=1.6,size=4)+
 blank_theme+
 ggtitle("Quelle est votre niveau de satisfaction sur 
 la procédure de gestion des réclamations \n ?")+theme_classic()+
 scale_y_continuous(labels=percent,breaks=NULL)+
 xlab("Procédure de gestion des réclamations") 

The problem is that i get stacked percenteges over just one bar. this is the output

How can i solve it to ajust percentages ?

Karima Touati
  • 37
  • 2
  • 7
  • Add a `position` argument to `geom_text`: `geom_text(aes(....), position = position_dodge(0.8))` – rcs Aug 03 '16 at 21:17
  • it doesn't work. and i get this error : Error in collide(data, params$width, "position_dodge", pos_dodge, check.width = FALSE) : Neither y nor ymax defined – Karima Touati Aug 03 '16 at 22:13

0 Answers0