Seaborn Learning 06: grouped bar chart

import seaborn as sns
import matplotlib.pyplot as plt

data = sns.load_dataset("titanic")
print(data.head())

g = sns.catplot(x="class", y="survived", hue="sex", data=data, height=6, kind="bar", palette="muted")
g.set_ylabels("survival probability")
plt.show()

operation result:

   survived  pclass     sex   age  ...  deck  embark_town  alive  alone
0         0       3    male  22.0  ...   NaN  Southampton     no  False
1         1       1  female  38.0  ...     C    Cherbourg    yes  False
2         1       3  female  26.0  ...   NaN  Southampton    yes   True
3         1       1  female  35.0  ...     C  Southampton    yes  False
4         0       3   
 male  35.0  ...   NaN  Southampton     no   True

display effect:

Guess you like

Origin www.cnblogs.com/jumpkin1122/p/11519429.html