I am trying to abstract some plugins in mpld3, and depending on which type of plot is contained in my figure (ie scatter vs. line vs. contour), I want to use a different plugin. I'm having trouble figuring out the canonical way to distinguish the category of a matplotlib axes. Right now, I'm inspecting the return of the various calls:
For a scatter plot:
type(plt.scatter(range(10), range(10)))
**matplotlib.collections.PathCollection**
For a line plot:
x = plt.plot([1,2,3])
print x
**[<matplotlib.lines.Line2D at 0xcd646ec>]**
For an image plot:
type(ax.imshow(np.random.randn(50,50)))
**matplotlib.image.AxesImage**
Etc...
Is there a more canonical way to access the axes type from the axes itself? Something like:
if ax.plottype == 'scatter':
....
elif ax.plottype == 'contour':
....
I guess since I can stack multiple artists onto a plot, maybe this is just not a sensible question?