這是我的圖表:
不幸的是,這也在那里,就在下面:

這是代碼:
fig,ax1 = plt.subplots(6,1, figsize=(20,10),dpi=300)
fig2,ax2 = plt.subplots(6,1, figsize=(20,10),dpi=300)
for index, val in enumerate(datedf.columns):
g = ax1[index].plot(datedf.index, datedf[val], color=colors[index])
ax1[index].set(ylim=[-100,6500])
ax2[index] = ax1[index].twinx()
a = ax2[index].plot(qtydf.index, qtydf[val], color=colors[index], alpha=0.5)
ax2[index].set(ylim=[200,257000])
我試過這個答案,但我在第一行出錯(解包的值太多)誰能解釋為什么?
uj5u.com熱心網友回復:
您生成了 2 個數字,因此最終得到 2 個數字。
相反,您應該執行以下操作:
fig, axes = plt.subplots(6,1, figsize=(20,10),dpi=300)
for index, val in enumerate(datedf.columns):
ax1 = axes[index]
g = ax1.plot(datedf.index, datedf[val], color=colors[index])
ax1.set(ylim=[-100,6500])
ax2 = ax1.twinx()
ax2.plot(qtydf.index, qtydf[val], color=colors[index], alpha=0.5)
ax2.set(ylim=[200,257000])
注意。該代碼未經測驗,因為我沒有原始資料集。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/367148.html
標籤:Python matplotlib
上一篇:如何對堆疊的條形圖進行分組?(對幾個堆疊的條形圖使用相同的標簽)
下一篇:4D混沌系統Lyapunov指數
