Tuesday 2:55 PM–3:35 PM in Central Park West (6501)

Building a maintainable plotting library

Colin Carroll, Hannah Aizenman, Thomas Caswell

Audience level:
Novice

Description

Fluid data visualization needs to be aware of the explicit and implicit structure of the data you want to visualize. Whether you are working on a personal project, or want to have a consistent set of figures for your company or lab, we will share tips on how to build a custom library using matplotlib that is easy to use, easy to maintain, easy to extend, and customized to your use case.

Abstract

There is something compelling about a data visualization that lets us explore a data set, comprehend an analysis, or think about a concept. A common desire for companies, labs, open source projects, and weekend hacks is to have a collection of easy-to-use visualizations that “do the right thing” in the context of your data. In the larger Python data science stack, this means that the visualizations must play nicely with matplotlib (or another exciting visualization library!), and probably libraries like numpy, pandas, and xarray.

First we will show you how to use a custom stylesheet, which is a low-effort, high-return way of having a distinctive, stylish, and uniform look by default.

For stand-alone plotting functions and quick projects, we give a few tips and best practices: how to get and update your figure and axes, what sort of arguments to accept and return, and how to write unit tests.

We also who how to about implement custom performant functionality using Artists. There are a few built-in artists that the common matplotlib functions are built with, and comfort with these may be particularly useful for library authors, or when you find you are reusing certain patterns in multiple visualizations.

We conclude with a discussion of building a custom Artist, which is useful when performance becomes an issue, when you expect other functions may want to use it, or when you really need to do something extra creative.

Subscribe to Receive PyData Updates

Subscribe