Pandas groupby plot with different X-Axis order

Viewed 1963

I'm working on titanic.csv, and trying to make some plots. Running into one issue. How can I re-organize the x-axis to place the same pclass value next to each other.

my current code:

titanic.groupby(['Sex', 'Pclass'])['Survived'].mean().plot(kind='bar', color=my_colors)

produce the following chart: enter image description here

I'd like to place the male and female from same class next to each other to show the difference in survival rate. Any suggestion?

2 Answers
Related