- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
看着matplotlib
文档,这似乎是添加 AxesSubplot
的标准方法到 Figure
是使用 Figure.add_subplot
:
from matplotlib import pyplot
fig = pyplot.figure()
ax = fig.add_subplot(1,1,1)
ax.hist( some params .... )
AxesSubPlot
- 独立于图形的对象,因此我可以在不同的图形中使用它们。就像是
fig = pyplot.figure()
histoA = some_axes_subplot_maker.hist( some params ..... )
histoA = some_axes_subplot_maker.hist( some other params ..... )
# make one figure with both plots
fig.add_subaxes(histo1, 211)
fig.add_subaxes(histo1, 212)
fig2 = pyplot.figure()
# make a figure with the first plot only
fig2.add_subaxes(histo1, 111)
matplotlib
中是否可行?如果是这样,我该怎么做?
def plot_axes(ax, fig=None, geometry=(1,1,1)):
if fig is None:
fig = plt.figure()
if ax.get_geometry() != geometry :
ax.change_geometry(*geometry)
ax = fig.axes.append(ax)
return fig
最佳答案
通常,您只需将轴实例传递给函数。
例如:
import matplotlib.pyplot as plt
import numpy as np
def main():
x = np.linspace(0, 6 * np.pi, 100)
fig1, (ax1, ax2) = plt.subplots(nrows=2)
plot(x, np.sin(x), ax1)
plot(x, np.random.random(100), ax2)
fig2 = plt.figure()
plot(x, np.cos(x))
plt.show()
def plot(x, y, ax=None):
if ax is None:
ax = plt.gca()
line, = ax.plot(x, y, 'go')
ax.set_ylabel('Yabba dabba do!')
return line
if __name__ == '__main__':
main()
def subplot(data, fig=None, index=111):
if fig is None:
fig = plt.figure()
ax = fig.add_subplot(index)
ax.plot(data)
import matplotlib.pyplot as plt
fig1, ax = plt.subplots()
ax.plot(range(10))
fig2 = plt.figure()
fig2.axes.append(ax)
plt.show()
关于python - matplotlib:我可以创建 AxesSubplot 对象,然后将它们添加到 Figure 实例吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49069712/
我正在尝试了解 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 中绘制圆圈的文档,但找不到任何内
我是一名优秀的程序员,十分优秀!