How to manually scale a continuous legend in a seaborn scatterplot?

Viewed 330

I'm creating a scatterplot with seaborn like this:

plt.figure(figsize=(20,5))
ax = sns.scatterplot(x=x,
        y=y,
        hue=errors,
        s=errors*20,
        alpha=0.8,
        edgecolors='w')
ax.set(xlabel='X', ylabel='Y')
ax.legend(title="Error (m)", loc='upper right')

My errors contain values between approximately 0.1 and 12.5. However, for my legend seaborn automatically generates labels 0, 5, 10, 15. This makes my algorithm look worse than it is. I would like to change the step size in the legend while maintaining a correct mapping between colors and error magnitudes. For example 0, 4, 8, 12.5. Is this possible?

0 Answers
Related