limit the number of groups shown in seaborn countplot?

后端 未结 2 591
借酒劲吻你
借酒劲吻你 2020-12-24 13:23

Is it possible to show only the top/bottom n groups in asns.countplot()?

Using an example from the seaborn website,

sns.countplot         


        
2条回答
  •  悲&欢浪女
    2020-12-24 14:02

    Just adding real example instead of toy dataset. Assuming you have Pandas Data Frame name training_var and you want to display top 10 'Gene' column counts 'order=' bit should look as follows:

    sb.countplot(x='Gene',data=training_var,order=pd.value_counts(training_var['Gene']).iloc[:10].index)
    

提交回复
热议问题