I'm trying to add some custom behaviors and properties to my figures, but I'm having trouble deciding on an effective (and Pythonic) approach.
My first impulse is to simply subclass matplotlib.figure.Figure
but I can't figure out how to accomplish this: I generally create new figures and start my plotting with something like
fig, ax = matplotlib.pyplot.subplots()
and I can't figure out how this would work with a custom Figure
subclass.
How can I subclass Figure
in a way that still lets me use pyplot
methods like the one above? Is subclassing even the right way to get custom behaviors associated with a figure? Are the better approaches?
subplots
takes additional keyword arguments that are passed directly tofigures()
, one of which is the class used to create the figures.