Seaborn因子图 [英] Seaborn factorplot

查看:45
本文介绍了Seaborn因子图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建因子图,但是无法将其类型从点更改为条形.我们该怎么做?

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?

使用的代码是

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

推荐答案

seaborn文档包含您要查找的确切示例.按照文档操作,如果运行以下几行,则应生成显示的条形图.

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.

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)

这里要注意的重要论点是kind="count".

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

这篇关于Seaborn因子图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆