Skip to content

Instantly share code, notes, and snippets.

@tjvananne
Last active August 6, 2017 18:22
Show Gist options
  • Save tjvananne/626ce92975416d080b59585e0bb3450c to your computer and use it in GitHub Desktop.
Save tjvananne/626ce92975416d080b59585e0bb3450c to your computer and use it in GitHub Desktop.
Create a Heat Map in R using ggplot2 with viridis Color Scale
# references:
# https://rud.is/b/2016/02/14/making-faceted-heatmaps-with-ggplot2/
# This is basically the TL;DR and it also uses a built-in dataset to foster reproducibility
library(ggplot2)
library(viridis)
gg <- ggplot(airquality, aes(x=Day, y=Month, fill=Temp))
gg <- gg + geom_tile(color='White', size=0.1)
gg <- gg + scale_fill_viridis(name="Temperature")
gg <- gg + coord_equal() + ggtitle("Sample Heat Map for Population")
gg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment