首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >有一个类matplotlib.axes.AxesSubplot,但模块matplotlib.axes没有属性AxesSubplot

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

Stack Overflow用户
提问于 2012-07-27 23:08:17
回答 1查看 18.1K关注 0票数 29

代码

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。

EN

回答 1

Stack Overflow用户

发布于 2019-11-17 02:10:12

了解DSM所说内容的另一种方式:

In [1]: from matplotlib import pyplot as plt                                                                                                                                                                       

In [2]: type(plt.gca()).__mro__                                                                                                                                                                                    
Out[2]: 
(matplotlib.axes._subplots.AxesSubplot,
 matplotlib.axes._subplots.SubplotBase,
 matplotlib.axes._axes.Axes,
 matplotlib.axes._base._AxesBase,
 matplotlib.artist.Artist,
 object)

使用dunder method resolution order,您可以找到某个类的所有继承。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11690597

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档