1治筒、導包
import matplotlib.pyplot as plt
2怠李、準備數(shù)據(jù)
x=df.index.tolist()
y1=df['列標簽1'].values.tolist()
y2=df['列標簽2'].values.tolist()
3蚜锨、準備畫布
fig=plt.figure(figsize=(20,8),dpi=80)
ax=fig.add_subplot(1,1,1)? #添加axes坐標軸實例
4眉枕、繪制第一個y軸
line1=ax.plot(x,y1,label='y1')
ax.set_xlabel='日期'
ax.set_ylabel='y1'
ax.legend(loc=0)
5焚志、繪制第二個y軸
ax2=ax.twinx()
line2=ax2.plot(x,y2,label='y2')
ax.set_ylabel='y2'
ax.legend(loc=1)
6嘱腥、合并圖例
lines=line1+line2
labels=[label.get_label()? for lable in lines]
ax.legend(lines,labels)