Edit seaborn legend

后端 未结 3 928
既然无缘
既然无缘 2020-11-29 21:14

Using a data frame and this code in Python, I was able to create a plot:

g = sns.lmplot(\'credibility\', \'percentWatched\', data=data, hue = \'millennial\',         


        
3条回答
  •  失恋的感觉
    2020-11-29 22:09

    Took me a while to read through the above. This was the answer for me:

    import seaborn as sns
    import matplotlib.pyplot as plt
    tips = sns.load_dataset("tips")
    
    g = sns.lmplot(
        x="total_bill", 
        y="tip", 
        hue="smoker", 
        data=tips,  
        legend=False
    )
    
    plt.legend(title='Smoker', loc='upper left', labels=['Hell Yeh', 'Nah Bruh'])
    plt.show(g)
    

    Reference this for more arguments: matplotlib.pyplot.legend

提交回复
热议问题