Home > Back-end >  Change in color of legend not reflected in the plot
Change in color of legend not reflected in the plot

Time:06-16

I'm trying to change the colour of the '0's in my plot to red. I could change the colour of the legend but this isn't reflecting to that dots in the scatter plot. How do I fix this? enter image description here

CodePudding user response:

As the data is not available above, I am assuming that over_50['target'] has only two values - 0 or 1. In that case, you should be using palette to assign colors. legend_handles will update the colors and not the graph.

I am using a sample code to show this....

import seaborn as sns
tips = sns.load_dataset("tips")
sns.scatterplot(data=tips, x="total_bill", y="tip", hue="time", palette = ['r', 'g']) #Red and Green

Output enter image description here

  • Related