I would like to have my stacked bar chart positioned along the x-axis based on total value. The default positioning is based on alphabetic order.
I used the following code to plot the stacked bar chart:
Country1 <- c(rep("Italy" , 3) , rep("Hungary" , 3) , rep("Belgium" , 3))
Shortage1 <- rep(c("Not relevant" , "Presumably active" , "Active") , 3)
Value1 <- c(11,823,480,1083,118,147,1,285,619)
DFshortage <- data.frame(Country1, Shortage1, Value1)
ggplot(DFshortage, aes(fill=Shortage1, y=Value1, x=Country1)) +
geom_bar(position="stack", stat="identity")
The output is as follows stacked bar chart
I would like to change the position of the bars based on total value, so the correct order should become Hungary, Italy, Belgium.