Alternative to Grouped Bar Charts in R
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
The #spiffy @dseverski gave me this posit the other day:
Hey, @hrbrmstr, doughnut chart aside, how would you approach the first graph at http://t.co/zjHoHRVOeo? Bump chart? Trend line? Leave as is?
— David F. Severski (@dseverski) October 25, 2013
and, I obliged shortly thereafter, but figured I’d toss a post up on the blog before heading to Strata.
To rephrase the tweet a bit, Mr. Severski asked me what alternate encoding I’d use for this grouped bar chart (larger version at the link in David’s tweet):

I have almost as much disdain for grouped bar charts as I do for pie or donut charts, so appreciated the opportunity to try a makeover. However, I ran into an immediate problem: the usually #spiffy 451 Group folks did not include raw data. So, I reverse engineered the graph with WebPlotDigitizer, cleaned up the result and made a CSV from it. Then, I headed to RStudio with a plan in mind.
The old chart and data screamed faceted dot plot. The only trick necessary was to manually order the factor levels.
library(ggplot)
# read in the CSV file
nosql.df <- read.csv("nosql.csv", header=TRUE)
# manually order facets
nosql.df$Database <- factor(nosql.df$Database,
levels=c("MongoDB","Cassandra","Redis","HBase","CouchDB",
"Neo4j","Riak","MarkLogic","Couchbase","DynamoDB"))
# start the plot
gg <- ggplot(data=nosql.df, aes(x=Quarter, y=Index))
# use points, colored by Quarter
gg <- gg + geom_point(aes(color=Quarter), size=3)
# make strips by nosql db factor
gg <- gg + facet_grid(Database~.)
# rotate the plot
gg <- gg + coord_flip()
# get rid of most of the junk
gg <- gg + theme_bw()
# add a title
gg <- gg + labs(x="", title="NoSQL LinkedIn Skills Index\nSeptember 2013")
# get rid of the legend
gg <- gg + theme(legend.position = "none")
# ensure the strip is gone
gg <- gg + theme(strip.text.x = element_blank())
gg |
The result is below in SVG form (install a proper browser if you can’t see it, or run the R code 🙂 I think it conveys the data in a much more informative way. How would you encode the data to make it more informative and accessible?
Full source & data over at github.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.