Python 如何在matplotlib中将第三个条形图添加到条形图中

Python 如何在matplotlib中将第三个条形图添加到条形图中,python,matplotlib,Python,Matplotlib,我有三个系列:薪水(int)、所有权(float)和保险(float) 我可以让系列中的两个在条形图上很好地显示出来,但是当我尝试添加第三个时,它会把一切都搞糟。我错过了什么 salary = np.round(new_player_df.groupby('Team')['Salary'].mean()) ownership = np.round(new_player_df.groupby('Team')['Own'].mean() * 100,3) cover = new_player_df.

我有三个系列:薪水(int)、所有权(float)和保险(float)

我可以让系列中的两个在条形图上很好地显示出来,但是当我尝试添加第三个时,它会把一切都搞糟。我错过了什么

salary = np.round(new_player_df.groupby('Team')['Salary'].mean())
ownership = np.round(new_player_df.groupby('Team')['Own'].mean() * 100,3)
cover = new_player_df.groupby('Team')['Cover_Prob'].mean()
salary = salary.sort_values()
ownership = ownership.sort_values()

fig = plt.figure() # Create matplotlib figure

ax = fig.add_subplot(111) # Create matplotlib axes
ax2 = ax.twinx() # Create another axes that shares the same x-axis as ax.
# ax3 = ax2.twinx() # Create another axes that shares the same x-axis as ax.
width = 0.4

salary.plot(kind='bar', color='red', ax=ax, width=width, position=0)
ownership.plot(kind='bar', color='blue', ax=ax2, width=width, position=1)
# cover.plot(kind='bar', color='green', ax=ax2, width=width, position=2) 
ax.set_ylabel('Cover')
ax2.set_ylabel('Ownership')
plt.show()

第三个系列应该绘制在哪个y轴上,第一个系列还是第二个系列?第二个@bigben可能比您当前的方法更简单的选择是在新的数据帧中获取转换后的数据,并使用
secondary\u y
进行绘制,例如:
df.plot.bar(ax=ax,secondary\u y=['owner','cover'],…)
第三个系列应该绘制在哪个y轴上,第一个系列还是第二个系列?第二个@bigben可能比您当前的方法更简单的选择是在一个新的数据框中获取转换后的数据,并使用
secondary\u y
进行绘制,例如:
df.plot.bar(ax=ax,secondary\u y=['owner',cover',…)