We just need to rearrange the data into a long format. Then plot, making sure we only give a subset of the data to geom_tile
. Then we rearrange the axis ordering.
library(ggplot2)
dat2 <- stack(dat[-1])
dat2$year <- dat$Year
ggplot(mapping = aes(ind, year)) +
geom_tile(aes(fill = values), subset(dat2, year != "Average" & ind != "Sum")) +
geom_text(aes(label = round(values, 1)), dat2) +
scale_y_discrete(limits = c("Average", 2017:1999)) +
scale_x_discrete(limits = c(month.abb, "Sum"), position = "top") +
viridis::scale_fill_viridis() +
theme_minimal() + theme(axis.title = element_blank())