Unable to show legend in seaborn distplot

As you have already labelled your plots using label= inside your sns.distplot then all you have to do is show your legend. This is done by adding plt.legend() just before plt.show()

More information on matplotlib legends can be found in the documentation


I found some issue using "fig.legend()" to adding labels into legend in seaborn histogram. It reverse colors order in legend without changing colors of histogram bars...

fig.legend(labels=['label1','label2',...])

Histogram before using fig.legend()

Histogram after using fig.legend()

Modules versions:

  • seborn '0.11.0'
  • matplotlib '3.1.3'

Simple solution is to reverse the order of label_list by appling label_list.reverse() but I don't consider it as good solution. I don't have idea what is happening and how to block reversing the order of colors in legend.


By using fig.legend we can show legends in the distribution plot. Here, an argument array of labels is passed to the function. Labels in the legend will also be displayed as an order of array values.

import seaborn as sns
import matplotlib.pyplot as plt

fig = plt.figure(figsize=(10,6))
lst1 = list(np.random.rand(10))
lst2 = list(np.random.rand(10))
sns.distplot(lst1)
sns.distplot(lst1)
fig.legend(labels=['test_label1','test_label2'])
plt.show()