Season's greetings from matplotlib

If working on XKCD style plotting for matplotlib taught me anything, it is that playing with software in a way that it was not originally designed to do can lead to some excellent discoveries (bugs) and generate new ideas and generalisations - not to mention it being a lot of fun!

So, in that vein, I wanted to put together a simple Christmas e-card using matplotlib. My main aim was to re-purpose some of the familiar matplotlib functionality to generate a simple festive animation.

I decided to go for a snowy scene, with a snow-capped greeting and sprig of holly. The snow is simply a scatter plot scaled by flake size and animated to fall in a pleasing way. The text is making use of the path effects functionality extended in v1.4 to add randomised “snow” around the text (the same effect employed by XKCD as it happens). And the holly is a nice demonstration of the power of Paths and vector rendering in matplotlib.

The source can be found at https://gist.github.com/pelson/ca795a02a420a1b9bfbc, and it requires matplotlib >= v1.4.

If you’re impatient and don’t want to run the code (don’t do it), the animation is available on YouTube at https://www.youtube.com/watch?v=POnAkPpe770.

Finally, to all those taking some time off this festive season, I wish you a very happy holiday and wish you all the best for the new year.

Phil Elson