Consider the titanic dataset, I'd like to plot a bar graph showing how sex and passenger class impact survival. I used the code below to groupby sex and passenger class to produce the attached figure. How can I eliminate the gender variable from the x-axis and express it as a color (shading the men with blue and the women with red, for example)?
import pandas as pd
data = pd.read_csv("train.csv")
data[['Sex','Pclass','Survived']].groupby(['Sex','Pclass']).sum().plot.bar()
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments