If you have to use circles…

February 15, 2012
By

(This article was first published on Quantum Forest » rblogs, and kindly contributed to R-bloggers)

Stats Chat is an interesting kiwi site—managed by the Department of Statistics of the University of Auckland—that centers around the use and presentation of statistics in the media. This week there was an interesting discussion on one of those infographics that make you cringe:

I understand the newspaper’s need to grab our attention, as well as the designer’s esthetical considerations, but they have to follow avoiding misleading the reader and providing at least a ball-park idea of the importance of whatever issue is under discussion. Clearly, as pointed out in the discussion, a line chart would convey the message with a minimum of ink; however, the designer may still want to use circles, and here we could go back to a faceted version of the always maligned pie chart.

Faceted pie charts using ggplot2

The code reads the data, reshapes it and plots it using pretty much the explanation for pie charts in the ggplot2 documentation.

# 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
view raw pie-charts.R This Gist brought to you by GitHub.

Again, please remember my typical disclaimer about lack of design and color flair. Colors and scales need work, but I think it is an improvement over the original.

To leave a comment for the author, please follow the link and comment on his blog: Quantum Forest » rblogs.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Tags: , , ,

Comments are closed.