Remove seaborn lineplot legend title

前端 未结 3 524
无人共我
无人共我 2020-12-02 15:43

I would like to remove the title from my seaborn lineplot legend. I tried using this answer to no avail:

import matplotlib.pyplot as plt
import seaborn as sn         


        
3条回答
  •  南笙
    南笙 (楼主)
    2020-12-02 16:18

    Extending ImportanceOfBeingErnest's answer:

    I had the same problem, but the 'Removing the label' example removed the title and first item from the actual legend.

    handles, labels = ax.get_legend_handles_labels()
    ax.legend(handles=handles[1:], labels=labels[1:])
    

    So, this removes just the legend title:

    handles, labels = ax.get_legend_handles_labels()
    ax.legend(handles=handles, labels=labels)
    

提交回复
热议问题