- This issue seems to be resolved for
matplotlib==3.3.2
.
- With
matplotlib
version 3.3.1
- A workaround is to send a
list
to hue
, by using .tolist()
- Use
hue=tips.time.tolist()
.
- The normal behavior adds a
title
to the legend, but sending a list
to hue
does not add the legend title.
- The legend title can be added manually.
import seaborn as sns
# load data
tips = sns.load_dataset("tips")
# But adding 'hue' gives the error below:
ax = sns.scatterplot(x="total_bill", y="tip", hue=tips.time.tolist(), data=tips)
ax.legend(title="time") # add a title to the legend