问题
I have the following view:
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.
Any thoughts?
回答1:
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'])
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]
来源:https://stackoverflow.com/questions/57881260/ordering-y-axis-of-seaborn-boxplot