fig1, ax1 = plt.subplots() # 调用figure创建一个绘图对象
plt.bar(data.index, data['IC'], width=15)
plt.grid(True)
ax2 = ax1.twinx()
plt.plot(data.index, data['nav'])
fig1.savefig(SigleFactor.picture_path + factor + '_IC.png')
plt.close(fig1)
以上代码画双 Y 轴的图片,效果如下,图片中纵坐标有两条实线,有什么办法优化下吗
1 把grid线关掉
2 set_ylim, 两个y的limit要合理
3 把数调整到一个y空间内使用一个y坐标画出来, 最后再补上一条调整的y轴。