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

# pandas.DataFrame.plot.bar
recent_grads[:3].sort_values("ShareWomen", ascending=False).plot.bar(x='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')
plt.xlabel('')

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.

https://stackoverflow.com/questions/53577630/how-to-make-pareto-chart-in-python

1 Like

Hello,

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.

Best,
Dilara