在多个比例图上对齐y轴

时间:2020-07-29 23:07:41

标签: python-3.x matplotlib plot

我有以下代码块

fig, ax1 = plt.subplots(1,1) 

my_norm = Normalize(vmin=0, vmax=component_stats.u_id.max())
ax1.bar(component_stats.index, component_stats["u_id"],color=cm(my_norm(component_stats["u_id"].array)),width=0.1)

ax2 = ax1.twinx()
ax2.plot(component_stats.index, component_stats["diff"],":",linewidth=3)

我有两个不重合的y轴

enter image description here

为什么会这样?我该如何解决?

0 个答案:

没有答案