有一个matplotlib.axes.AxesSubplot类,但是模块matplotlib.axes没有属性AxesSubplot

问题描述 投票:20回答:2

代码

import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111)
print type(ax)

提供输出

<class 'matplotlib.axes.AxesSubplot'>

然后输入代码

import matplotlib.axes
matplotlib.axes.AxesSubplot

引发例外

AttributeError: 'module' object has no attribute 'AxesSubplot'

总而言之,有一个类matplotlib.axes.AxesSubplot,但是模块matplotlib.axes没有属性AxesSubplot。到底是怎么回事?

我正在使用Matplotlib 1.1.0和Python 2.7.3。

python matplotlib
2个回答
22
投票

嘿。这是因为在从AxesSubplot构建一个类之前,没有[[is


0
投票
查看DSM所说的另一种方式:
© www.soinside.com 2019 - 2024. All rights reserved.