Xkcd-Style Plots in Matplotlib (2012)
Update: the matplotlib pull request has been merged! See This post for a description of the XKCD functionality now built-in to matplotlib!
If you, like me, frequently commute via public transit, you may be familiar with the following situation:
Visit jakevdp.github.io → RSS feedOn Hacker News Aug 2013 – Apr 2019
Software Engineering 6Databases & Data 6Math & Algorithms 4Society, Policy & Culture 1Science & Space 1Programming Languages 1
Update: the matplotlib pull request has been merged! See This post for a description of the XKCD functionality now built-in to matplotlib!
Update, August 2014: see Hacking Academia , my most recent reflection on this subject.
See also Frequentism and Bayesianism: A Python-driven Primer , a peer-reviewed article partially based on this content.
One of the most consistently popular posts on this blog has been my XKCDify post, where I followed in the footsteps of others to write a little hack for xkcd-style plotting in matplotlib. In it, I mentioned the Sketch Path Filter pull request that would eventually supersede my ugly little hack.
What this function does is to give you a lumninance-correct grayscale version of any matplotlib colormap. I've found this useful for quickly checking how my plots might appear if printed in black and white, but I think it's probably even more useful for stoking the flame of the internet's general rant against jet .
Of all the programming styles I have learned, dynamic programming is perhaps the most beautiful. It can take problems that, at first glance, look ugly and intractable, and solve the problem with clean, concise code. Where a simplistic algorithm might accomplish something by brute force, dynamic programming steps back…