I have defined some plots which I now like to arrange using subplots. So I will pass an axis object to the plot definition and tell it to plot on that instead of making a new plot. However, to make this fool-proof I like to check that the passed object is actually of the right type, i.e. an axis.
When I make a subplot like so: f, ax = pyplot.subfigure(2,2)
and inspect type(ax[1,1])
it returns matplotlib.axes._subplots.AxesSubplot
, however I cannot use isinstance()
to test against that value. What works is isinstace(ax[1,1],matplotlib.axes._subplots.Subplot)
. But I can also test against matplotlib.axes._subplots.Axes
or matplotlib.axes._subplots.SubplotBase
, all equate to True
. I'm a bit confused by the ambiguity here. What is the correct way to test if something is an object one can plot on?