合并子图错误-'AxesSubplot'对象没有属性'get_gridspec'

时间:2019-01-15 10:27:14

标签: python python-3.x python-2.7 matplotlib plot

使用python 2.7x,无法升级,因为我在托管Windows系统上。我正在尝试按照此示例合并子图,但返回以下错误:

  

“ AxesSubplot”对象没有属性“ get_gridspec”

我在这里查看了其他示例,但找不到来自我正在使用的构建的任何示例(Anaconda 2.7,Spyder IDE)示例,来自:

https://matplotlib.org/tutorials/intermediate/gridspec.html

virtual

1 个答案:

答案 0 :(得分:2)

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])