I have successfully created a stacked bar plot but I cannot add labels indicating the percentages. That is all that I am missing. I basically do not know how to use the geom_label/geom_text correctly, I have tried many many solutions but nothing has worked for me.
I have tried the geom_text function but it keeps telling me I am doing it wrong.
year Month2 Month Day HE Supply MUnit MPrice MBlock Fuel
2017 1 Jan 01 8 9408 SD2 15.38 126 COAL
2017 1 Jan 01 9 9388 SD3 15.46 218 COAL
2017 1 Jan 01 10 9393 SD3 15.46 218 COAL
2017 1 Jan 01 11 9628 SD4 15.47 203 COAL
2017 1 Jan 01 12 9943 EGC1 21.40 72 GAS
2017 1 Jan 01 13 10106 BR5 21.41 245 COAL
2017 1 Jan 01 14 10114 BR5 21.41 245 COAL
2017 1 Jan 01 15 9971 EGC1 20.75 75 GAS
2017 1 Jan 01 16 10302 BR5 21.41 245 COAL
2017 1 Jan 01 17 10655 TC01 22.77 11 GAS
2017 1 Jan 01 18 10811 CAL1 24.88 25 GAS
2017 1 Jan 01 19 10821 CAL1 24.88 25 GAS
2017 1 Jan 01 20 10765 BIG 26.00 30 HYDRO
2017 1 Jan 02 8 10428 CAL1 22.04 30 GAS
2017 1 Jan 02 9 10723 CAL1 29.97 59 GAS
2017 1 Jan 02 10 10933 BRA 44.50 30 HYDRO
2017 1 Jan 02 11 11107 ANC1 46.46 63 GAS
2017 1 Jan 02 12 11098 ANC1 46.46 38 GAS
2017 1 Jan 02 13 10839 JOF1 26.59 45 GAS
2017 1 Jan 02 14 10814 JOF1 26.09 15 GAS
2017 1 Jan 02 15 10797 BIG 26.00 30 HYDRO
sp <- ggplot(data = MU17) +
geom_bar(mapping = aes(x = factor(Month,levels=month.abb),
fill = factor(Fuel, levels=c("COAL", "GAS","HYDRO","BIOMASS"))),
position = "Fill") +
scale_y_continuous(labels = scales::percent)
sp + scale_fill_manual(breaks=c("COAL", "GAS","HYDRO","BIOMASS"),
values=c("black","yellow","blue","green")) +
labs(x = "2017" , y="Marginal Fuel Between HE8 & HE20") +
labs(fill="Fuel Type")
I am hoping to get the exact same plot that I get, just with labels indicating percentages.