The code
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111)
print type(ax)
gives the output
<class 'matplotlib.axes.AxesSubplot'>
Then the code
import matplotlib.axes
matplotlib.axes.AxesSubplot
raises the exception
AttributeError: 'module' object has no attribute 'AxesSubplot'
To summarize, there is a class matplotlib.axes.AxesSubplot, but the module matplotlib.axes has no attribute AxesSubplot. What on earth is going on?
I’m using Matplotlib 1.1.0 and Python 2.7.3.
Heh. That’s because there is no
AxesSubplotclass.. until one is needed, when one is built fromSubplotBase. This is done by some magic inaxes.py:So it’s made on the fly, but it’s a subclass of
SubplotBase: