Unable to show legend in seaborn distplot

前端 未结 3 983
猫巷女王i
猫巷女王i 2021-02-06 21:31

I am new to plotting in python and trying following code to plot distribution in seaborn but unable to see the legend, i.e., test_label1 and test

3条回答
  •  借酒劲吻你
    2021-02-06 22:10

    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.

提交回复
热议问题