作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
使用 python 2.7x,无法升级,因为我使用的是托管 Windows 系统。我尝试按照此示例合并子图,但返回以下错误:
'AxesSubplot' object has no attribute 'get_gridspec'
我已经查看了此处的其他示例,但找不到任何适用于我正在使用的构建(Anaconda 2.7、Spyder IDE)的示例:
https://matplotlib.org/tutorials/intermediate/gridspec.html
fig9 = plt.figure(constrained_layout=False)
gs1 = fig9.add_gridspec(nrows=3, ncols=3, left=0.05, right=0.48,
wspace=0.05)
f9_ax1 = fig9.add_subplot(gs1[:-1, :])
f9_ax2 = fig9.add_subplot(gs1[-1, :-1])
f9_ax3 = fig9.add_subplot(gs1[-1, -1])
gs2 = fig9.add_gridspec(nrows=3, ncols=3, left=0.55, right=0.98,
hspace=0.05)
f9_ax4 = fig9.add_subplot(gs2[:, :-1])
f9_ax5 = fig9.add_subplot(gs2[:-1, -1])
f9_ax6 = fig9.add_subplot(gs2[-1, -1])
最佳答案
查看documentation figure.add_gridspec
已在 matplotlib 3 及更高版本中添加。
对于 Python 3.5 及更高版本,您只需将 matplotlib 更新到最新版本即可运行该示例。但是,matplotlib 3 不适用于 Python 2.7 或 Python 3.4 及更低版本。
因此您可以使用old documentation中描述的旧方法。
import matplotlib.gridspec as gridspec
gs1 = gridspec.GridSpec(3, 3)
gs1.update(left=0.05, right=0.48, wspace=0.05)
ax1 = plt.subplot(gs1[:-1, :])
ax2 = plt.subplot(gs1[-1, :-1])
ax3 = plt.subplot(gs1[-1, -1])
关于python - 合并子图错误 - 'AxesSubplot' 对象没有属性 'get_gridspec',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54196979/
使用 python 2.7x,无法升级,因为我使用的是托管 Windows 系统。我尝试按照此示例合并子图,但返回以下错误: 'AxesSubplot' object has no attribute
我是一名优秀的程序员,十分优秀!