How to add secondary axis to python bar chart : Visualizing Earnings Based On Majors - guided project

recent_grads[:3].sort_values("ShareWomen", ascending=False)'Major', y='ShareWomen',
title='Share of Women in Top 3 Majors by Median Salary',
                          color = (0.5,0.1,0.6)
                         , legend=False)

plt.ylabel('Share of Women')

I do not want to only display share of women but also the median salary on the chart, so I wondered how to add a secondary axis to this bar chart so that I could have the median salary on another axis, and then display the median salary above each bar in the form of a line?

I am looking to make something like this but with median on the secondary axis so a different scale.

1 Like


I’d recommend you check out this guided project solution notebook, the very last cell. There’s a very similar plot to what you want to draw.