[Python] How to edit a seaborn legend title and labels for figure-level functions

Discussão em 'Python' iniciado por Stack, Maio 10, 2025.

  1. Stack

    Stack Membro Participativo

    I've created this plot using Seaborn and a pandas dataframe (data):

    [​IMG]

    My code:

    import seaborn as sns

    g = sns.lmplot('credibility', 'percentWatched', data=data, hue='millennial', markers=["+", "."])


    You may notice the plot's legend title is simply the variable name ('millennial') and the legend items are its values (0, 1). How can I edit the legend's title and labels? Ideally, the legend title would be 'Generation' and the labels would be "Millennial" and "Older Generations".

    Continue reading...

Compartilhe esta Página