Create a gist now

Instantly share code, notes, and snippets.

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