Skip to content

Instantly share code, notes, and snippets.

@joshbode
Created March 12, 2013 08:21
Show Gist options
  • Select an option

  • Save joshbode/5141117 to your computer and use it in GitHub Desktop.

Select an option

Save joshbode/5141117 to your computer and use it in GitHub Desktop.
library(plyr)
library(ggplot2)
d = data.frame(YEAR=as.ordered(rep(c(2001:2010), 10)), val=rnorm(1000))
p = ggplot(data=join(d, ddply(d, .(YEAR), function(x) { quantile(x$val) }))) +
geom_boxplot(aes(YEAR, val)) +
geom_text(aes(YEAR, `25%`, label=round(`25%`, 2)), stat='boxplot', vjust=-0.8, size=2) +
geom_text(aes(YEAR, `50%`, label=round(`50%`, 2)), stat='boxplot', vjust=-0.5, size=2) +
geom_text(aes(YEAR, `75%`, label=round(`75%`, 2)), stat='boxplot', vjust=+1.0, size=2) +
labs(x="Year", y="Value")
plot(p)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment