Home > Enterprise >  Exclude hue-variable from legend in pyplot
Exclude hue-variable from legend in pyplot

Time:10-01

I struggle finding a way of properly displaying only the labels respective to the markers in a scatterplot. My code looks as follows:

fig, ax = plt.subplots(1,1)
plot_white = sns.scatterplot(data=df_white, x='EngCorr_Player', y='EngCorr_Opponent', hue='Elo_Opponent', ax=ax, marker='D', label='White')
plot_black = sns.scatterplot(data=df_black, x='EngCorr_Player', y='EngCorr_Opponent', hue='Elo_Opponent', ax=ax, marker='X', s=140, label='Black')
ax.legend()
plt.show()

The problem here, is that the variable for the hue is included in the legend. enter image description here

  • Related