1

The class for a matplotlib axes is a AxesSubplot:

In [233]: type(gca())
Out[233]: matplotlib.axes.AxesSubplot

Yet this name does not appear to exist:

In [235]: import matplotlib.axes

In [236]: matplotlib.axes.AxesSubplot
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-236-d2888d8fac12> in <module>()
----> 1 matplotlib.axes.AxesSubplot

AttributeError: 'module' object has no attribute 'AxesSubplot'
2
In [237]: from matplotlib.axes import AxesSubplot
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-237-86d07b77aa8f> in <module>()
----> 1 from matplotlib.axes import AxesSubplot

ImportError: cannot import name AxesSubplot

It's not created using some fancy call of type() either; at least, grep AxesSubplot does not return any results on the module source file for the axes module.

If I look at its mro, I can access the definition for all other classes:

In [238]: type(gca()).mro()
Out[238]: 
[matplotlib.axes.AxesSubplot,
 matplotlib.axes.SubplotBase,
 matplotlib.axes.Axes,
 matplotlib.artist.Artist,
 builtins.object]

How is it possible that type(gca()) reports matplotlib.axes.AxesSubplot, yet this class appears not to exist there?

I'm on Python 3.2, Matplotlib 1.2, in case it matters.

gerrit
  • 24,025
  • 17
  • 97
  • 170

0 Answers0