【发布时间】:2015-06-01 18:30:04
【问题描述】:
我正在尝试使用以下代码在 python 中绘制一组图表。
fig = plt.figure(figsize=(12,8))
ax1 = fig.add_subplot(521)
fig = sm.graphics.tsa.plot_acf(s0, lags=40, ax=ax1)
ax2 = fig.add_subplot(522)
fig = sm.graphics.tsa.plot_pacf(s0, lags=40, ax=ax2)
fig = plt.figure(figsize=(12,8))
ax1 = fig.add_subplot(523)
fig = sm.graphics.tsa.plot_acf(s1, lags=40, ax=ax1)
ax2 = fig.add_subplot(524)
fig = sm.graphics.tsa.plot_pacf(s1, lags=40, ax=ax2)
fig = plt.figure(figsize=(12,8))
ax1 = fig.add_subplot(525)
fig = sm.graphics.tsa.plot_acf(s2, lags=40, ax=ax1)
ax2 = fig.add_subplot(526)
fig = sm.graphics.tsa.plot_pacf(s2, lags=40, ax=ax2)
fig = plt.figure(figsize=(12,8))
ax1 = fig.add_subplot(527)
fig = sm.graphics.tsa.plot_acf(s3, lags=40, ax=ax1)
ax2 = fig.add_subplot(528)
fig = sm.graphics.tsa.plot_pacf(s3, lags=40, ax=ax2)
fig = plt.figure(figsize=(12,8))
ax1 = fig.add_subplot(529)
fig = sm.graphics.tsa.plot_acf(s4, lags=40, ax=ax1)
ax2 = fig.add_subplot(5210)
fig = sm.graphics.tsa.plot_pacf(s4, lags=40, ax=ax4)
在我绘制了第 10 个子图并且第 10 个子图未显示在输出中的行中有错误。 代码如下
ax2 = fig.add_subplot(5210)
fig = sm.graphics.tsa.plot_pacf(s4, lags=40, ax=ax4)
而且报错信息如下
整数子图规范必须是三位数字。不是 4
我认为问题出在 (5210) 上。前两位指定图形的行和列,即 52 表示 5 列和 2 行,总共 10 个图形,第三位是指放置编号 i>e 1,2,3,...10。在 (529) 之前一切正常,但在 (5210) 中显示错误。
【问题讨论】:
标签: python matplotlib