Skip to content

Instantly share code, notes, and snippets.

@jlehtoma
Last active December 18, 2015 22:59
Show Gist options
  • Save jlehtoma/5858631 to your computer and use it in GitHub Desktop.
Save jlehtoma/5858631 to your computer and use it in GitHub Desktop.
library(reshape)
library(ggplot2)
dat <- data.frame(Paikka=rep(c("Hanko", "Helsinki","Turku"), 4),
Vuosi=factor(rep(c(2009, 2010, 2011, 2012), each=3)),
Prosentti=runif(12, 0, 1))
# Barplot
ggplot(dat, aes(Paikka, Prosentti, fill=Vuosi)) +
geom_bar(position="dodge", stat="identity")
# Lineplot
ggplot(dat, aes(Vuosi, Prosentti, group=Paikka, color=Paikka)) +
geom_line()
# Heatmap
ggplot(dat, aes(Vuosi, Paikka)) +
geom_tile(aes(fill = Prosentti), colour = "white") +
scale_fill_gradient(low = "white", high = "steelblue")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment