Plotting like xkcd

Posted on September 10, 2016 • Tagged with python, visualization

I have been using ggplot2 for years, and it has been my favourite plotting system. One thing I have been missing is an xkcd theme until I discovered recently that ggplot, the plotting system for Python based on ggplot2, comes with an xkcd theme.

Applying the xkcd theme with ggplot doesn't need much explanation: It's exactly the same as applying themes like theme_bw(). Let's just plot something using Fisher's Iris data set 1:

ggplot(iris_data, aes(x='sepal_length', colour='class')) +
                stat_density() +
                theme_xkcd()

xkcd_density

ggplot(iris_data, aes(x='class', y='petal_width')) +
                geom_boxplot() +
                theme_xkcd()

xkcd_box

So, when will The Oatmeal theme be added?


  1. Fisher's Iris data set is provided by UCI Machine Learning Repository, University of California, Irvine.