0
votes

In countplot legend for hue are placed at improper positition:

sns.countplot(x='cat114', hue='loss', data=data_tr)

Countplot

How do I change legend position? I tried plt.legend(loc='upper right') but it is not helping me.

1
Did you put plt.legend(loc='upper right') before or after the countplot?tdy
I put it after. I got my answer btw, g=sns.countplot(x=feature, hue='loss', data=data_tr, order=cat_order(feature)) g.figure.get_axes()[0].legend(loc='upper right')Sandeep Maurya
Sounds good. Feel free to post that as an official answer and accept it.tdy

1 Answers

0
votes
g=sns.countplot(x=feature, hue='loss', data=data_tr) 
g.figure.get_axes()[0].legend(title='loss',loc='upper right')