Skip to content

Instantly share code, notes, and snippets.

@zentree
Created February 15, 2012 06:51
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 zentree/1833838 to your computer and use it in GitHub Desktop.
Save zentree/1833838 to your computer and use it in GitHub Desktop.
Faceted Pie chart
# Location and libraries
require(reshape)
require(ggplot2)
setwd('~/Dropbox/quantumforest')
# Reading data and melting into long shape
bub = read.csv('bubble-data.csv', header = TRUE)
bub2 = melt(bub, id = 'year')
names(bub2)[2] = 'worry'
levels(bub2$worry)[3] = 'Something else'
# Pie charts; no, really, pie charts!
crazyPalette = scale_fill_manual(values = c('#7DADDD', '#EF1C22', '#BEC7D6'))
crazy = ggplot(bub2, aes(x = factor(1), y = value, fill = worry))
crazy = crazy + geom_bar(width = 1) + coord_polar(theta = 'y') +
facet_wrap(~ year) + crazyPalette +
scale_x_discrete('Worry per year (%)') + scale_y_continuous('')
crazy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment