【发布时间】:2017-08-20 22:17:55
【问题描述】:
我知道要为单个图获得多个比例,您可以使用:
fig, ax1 = plt.subplots()
ax2 = ax1.twinx()
ax1.plot(range(0,20,2))
ax2.plot(range(10))
但是,我需要为四个子图执行此操作。所以当我尝试这样的事情时:
fig, ax = plt.subplots(nrows=2, ncols=2)
for row in ax:
for col in row:
fig1, ax1 = col.subplots()
ax2 = ax2.twinx()
ax1.plot(range(0,20,2)
ax2.plot(range(10))
我得到了错误
'AxesSubplot' object has no attribute 'subplots'
,这是有道理的,但我不知道如何解决它。
【问题讨论】:
标签: python matplotlib plot subplot