public
Last active

Faceted Pie chart

  • Download Gist
pie-charts.R
R
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
# 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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.