订购seaborn boxplot的y轴? [英] Ordering y-axis of seaborn boxplot?

查看:42
本文介绍了订购seaborn boxplot的y轴?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下观点:

但我希望这里的 y 轴是有序的,这样 num_engagements 字段会随着 y 轴的上升而增加,而不是相反的情况.我试过在 seaborn 选项中使用 order 字段,但是如果我设置 order=['num_engagements'] 那么我只会得到一个空白图.

but I'd like to have the y-axis here ordered so the num_engagements field is increasing as the y-axis goes up instead of the reverse case here. I've tried playing with the order field in the seaborn options, but if I set order=['num_engagements'] then I just get a blank plot as a result.

有什么想法吗?

推荐答案

您需要将所有 y 轴标签的列表传递给您的订单关键字.以下将实现您想要的:

You need to pass in a list of all the y-axis labels to your order keyword. The following would achieve what you want:

sns.boxplot(y='num_engagements', x='channel_spend1', showfliers=False, 
            orient='h', data=rep_data_imputed, order=['13','12','11','10','9'])

需要注意的一点是,目前您的参与次数被视为分类变量,因此我将顺序指定为 ['13','12','11','10','9'],带单引号.如果它不起作用,请尝试 [13,12,11,10,9]

One thing to note, currently your number of engagement is being treated as a categorical variable, thus I specified the order as ['13','12','11','10','9'], with single quotation marks. If it doesn't work, try [13,12,11,10,9]

这篇关于订购seaborn boxplot的y轴?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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