限制seaborn计数图中显示的组数? [英] limit the number of groups shown in seaborn countplot?
本文介绍了限制seaborn计数图中显示的组数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以仅在a sns.countplot()
中显示前/后 n 个组?
Is it possible to show only the top/bottom n groups in asns.countplot()
?
使用Seaborn网站上的示例
Using an example from the seaborn website,
sns.countplot(y="deck", hue="class", data=titanic, palette="Greens_d");
是否有任何简单(甚至相对简单)的方法可以将此图限制为仅3个套(组)而不是全部显示7个图?这是否可以通过sns.bargraph
或仅使用matplotlib更好地完成?
Is there any easy (or even relatively straightforward) way of limiting this plot to just 3 decks (groups) instead of displaying all 7 or is this something that would be better accomplished with an sns.bargraph
or just plain matplotlib?
推荐答案
import seaborn as sns
titanic = sns.load_dataset("titanic")
sns.countplot(y="deck", hue="class", data=titanic, palette="Greens_d",
order=titanic.deck.value_counts().iloc[:3].index)
这篇关于限制seaborn计数图中显示的组数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文