Skip to content

Instantly share code, notes, and snippets.

@erzk
Created May 11, 2015 23:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erzk/7b846c5eb5695161d4b5 to your computer and use it in GitHub Desktop.
Save erzk/7b846c5eb5695161d4b5 to your computer and use it in GitHub Desktop.
library(ggplot2)
library(RColorBrewer)
# make the heatmap
# based on https://gist.github.com/dsparks/3710171
myPalette <- colorRampPalette(rev(brewer.pal(11, "Spectral")), space="Lab")
zp1 <- ggplot(foreign_victims_long,
aes(x = Year, y = Country, fill = Victims))
zp1 <- zp1 + geom_tile()
zp1 <- zp1 + scale_fill_gradientn(colours = myPalette(100))
zp1 <- zp1 + scale_x_discrete(expand = c(0, 0))
zp1 <- zp1 + scale_y_discrete(expand = c(0, 0))
zp1 <- zp1 + coord_fixed(ratio=2/3)
zp1 <- zp1 + theme_bw()
zp1 <- zp1 + theme(axis.text.x = element_text(angle=90, vjust=0))
print(zp1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment