1

matplotlib 軸のクラスは次のAxesSubplotとおりです。

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

しかし、この名前は存在しないようです:

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

いずれかの派手な呼び出しを使用して作成されたものではありませんtype()。少なくとも、grep AxesSubplotモジュールのモジュール ソース ファイルに関する結果は返されませんaxes

その mro を見ると、他のすべてのクラスの定義にアクセスできます。

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

type(gca())報告されているmatplotlib.axes.AxesSubplotにもかかわらず、このクラスが存在しないように見えるのはどうしてですか?

問題が発生した場合に備えて、私はPython 3.2、Matplotlib 1.2を使用しています。

4

0 に答える 0