- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
代码
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。
最佳答案
呵呵。那是因为 没有 AxesSubplot
类.. 直到需要一个,从 SubplotBase
构建一个。这是通过 axes.py
中的一些魔法完成的:
def subplot_class_factory(axes_class=None):
# This makes a new class that inherits from SubplotBase and the
# given axes_class (which is assumed to be a subclass of Axes).
# This is perhaps a little bit roundabout to make a new class on
# the fly like this, but it means that a new Subplot class does
# not have to be created for every type of Axes.
if axes_class is None:
axes_class = Axes
new_class = _subplot_classes.get(axes_class)
if new_class is None:
new_class = new.classobj("%sSubplot" % (axes_class.__name__),
(SubplotBase, axes_class),
{'_axes_class': axes_class})
_subplot_classes[axes_class] = new_class
return new_class
所以它是即时制作的,但它是 SubplotBase
的子类:
>>> import matplotlib.pyplot as plt
>>> fig = plt.figure()
>>> ax = fig.add_subplot(111)
>>> print type(ax)
<class 'matplotlib.axes.AxesSubplot'>
>>> b = type(ax)
>>> import matplotlib.axes
>>> issubclass(b, matplotlib.axes.SubplotBase)
True
关于python - 有一个类matplotlib.axes.AxesSubplot,但是模块matplotlib.axes没有属性AxesSubplot,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11690597/
我正在尝试了解 matplotlib API。我见过很多这样的例子: ... fig, (ax0, ax1) = plt.subplots(nrows=2) ax1.spines['right'].s
我正在尝试运行来自 here 的 basemap 示例我面临错误“AxesSubplot”对象没有属性“get_axis_bgcolor”。当我从该站点尝试第一个示例时,我应该收到黑色、水蓝色和陆地珊
我绘制了来自 pandas 的一些数据DataFrame在 Jupyter notebook像这样的单元格: ax = data.plot('Weight', 'Height', kind='
使用 python 2.7x,无法升级,因为我使用的是托管 Windows 系统。我尝试按照此示例合并子图,但返回以下错误: 'AxesSubplot' object has no attribute
这个问题在这里已经有了答案: understanding matplotlib.subplots python [duplicate] (1 个回答) 关闭 4 年前。 我正在尝试制作包含在两个数据
我想从从 pandas.Series.hist 返回的 matplotlib.axes.AxesSubplot 中获取值方法。有什么方法可以这样做吗?我在列表中找不到该属性。 import panda
所以我正在尝试使用 Axes 对象来控制我的 matlibplot 图。我没有使用 plt(又名 import matlibplot.pyplot as plt),因为我根据 this 将图形嵌入到我
我有一个对象 fig2,它是一个类 mathplotlib.axes.axessubplot,但是当我尝试执行 fig2.show() 时,python 说 axessubplot 对象没有属性显示。
在寻找Matplotlib get subplot (axes) size?的答案,我意识到 ax1、ax2 变量属于 AxesSubplot 类。 但是,我在任何地方都找不到关于此的任何文档 - 例
有什么方法可以获取指向子图中的 AxesImage 实例的指针吗?例如,在一般情况下,例如: import matplotlib.pyplot as plt import numpy as np da
不确定如何修复以下属性错误: AttributeError: 'AxesSubplot' object has no attribute 'add_axes' 问题似乎与我设置情节的方式有关: gri
代码 import matplotlib.pyplot as plt fig = plt.figure() ax = fig.add_subplot(111) print type(ax) 给出输出
我想绘制一个堆叠条形图,其中的数据来自 Pandas 中的两个独立数据框(My_means 和 My_stds)。我正在使用 Python 3.7。 绘图调用工作正常,但是,标签被切断。设置 tiny
我正在使用导入为 PL 的 matplotlib.pyplot 制作绘图: FIG = PL.figure(figsize=(12,8), dpi=150) AX = FIG.add_subplot(
import pandas as pd import matplotlib.pyplot as plt file = 'd:\\a\\pandas\\test.xlsx' data = pd.Exce
查看 matplotlib 文档,似乎将 AxesSubplot 添加到 Figure 的标准方法是使用 Figure。添加子图: from matplotlib import pyplot fig
我换了一台新电脑,安装了Python3.6和matplotlib,上个月在旧电脑上运行代码时,出现如下错误: ax.hold(真) AttributeError: 'AxesSubplot' 对象没有
看着matplotlib文档,这似乎是添加 AxesSubplot 的标准方法到 Figure是使用 Figure.add_subplot : from matplotlib import pyplo
查看 matplotlib 文档,似乎将 AxesSubplot 添加到 Figure 的标准方法是使用 Figure。 add_subplot: from matplotlib import pyp
我正在尝试将轨道模拟嵌入到 tkinter 框架中,我的绘图工作正常我现在只是尝试将圆圈输入到图表中以表示行星。我查看了有关如何在 FigureCanvasTkAgg 中绘制圆圈的文档,但找不到任何内
我是一名优秀的程序员,十分优秀!