Created
February 15, 2012 06:51
-
-
Save zentree/1833838 to your computer and use it in GitHub Desktop.
Faceted Pie chart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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