Seaborn factorplot

爷,独闯天下 提交于 2021-01-29 08:31:34

问题


I am trying to create a factor plot but I am not able to change the kind of it from point to bar. How do we do that?

The codes used are

 import numpy as np
 import matplotlib.pyplot as plt
 import seaborn as sns
 %matplotlib inline
 sns.catplot('Sex',kind="bar",data=titanic_df)

回答1:


The seaborn documentation has the exact example you are looking for. Following the documentation, if you run the below lines, it should generate the bar plot shown.

bar plot generated from the code

import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline

titanic = sns.load_dataset("titanic")
exercise = sns.load_dataset("exercise")
g = sns.catplot("alive", col="deck", 
                col_wrap=3, data=titanic[titanic.deck.notnull()], 
                kind="count", height=2.5, aspect=.8)

The important argument to note here is kind="count".



来源:https://stackoverflow.com/questions/55578458/seaborn-factorplot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!