library(ggplot2) #dataframe location <- c(rep("Lygra", 12), rep("Østerbø", 12)) month <- c(rep(c("Jan","Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"), 2)) precipitations <- c(109.8, 52.8, 37.7, 69.8, 50.8, 47.3, 30.7, 186.3, 294.6, 245.9, 57.6, 46.4, 48.0, 11.2, 5.6, 24.2, 17.2, 31.6, 43.4, 75.3, 144.0, 103.0, 12.4, 36.6) df <- data.frame(location, month, precipitations) #stacked graph with viridis ggplot(df, aes(location, precipitations, fill=month)) + geom_col() + scale_fill_viridis_d() #reorder legend ggplot(df, aes(location, precipitations, fill=month)) + geom_col() + scale_fill_viridis_d(breaks=c("Jan","Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")) #force the order of the months in the dataframe location <- c(rep("Lygra", 12), rep("Østerbø", 12)) month <- factor(rep(month.name, 2),levels=month.name) precipitations <- c(109.8, 52.8, 37.7, 69.8, 50.8, 47.3, 30.7, 186.3, 294.6, 245.9, 57.6, 46.4, 48.0, 11.2, 5.6, 24.2, 17.2, 31.6, 43.4, 75.3, 144.0, 103.0, 12.4, 36.6) df2 <- data.frame(location, month, precipitations) ggplot(df2, aes(location, precipitations, fill=month)) + geom_col() + scale_fill_viridis_d() #add labels to the elements ggplot(df2, aes(location, precipitations, fill=month)) + geom_col() + scale_fill_viridis_d() + geom_text(aes(label = precipitations), position = position_stack()) #adjust labels ggplot(df2, aes(location, precipitations, fill=month)) + geom_col() + scale_fill_viridis_d() + geom_text(aes(label = precipitations), position = position_stack(vjust = .5), color="RED", size=3.5)