AttributeError: Unknown property legend in seaborn

AttributeError: Unknown property legend in seaborn

seaborn stripplot 具有允许 hue 的功能。

使用 https://stanford.edu/~mwaskom/software/seaborn/generated/seaborn.stripplot.html

中的示例
import seaborn as sns
sns.set_style("whitegrid")
tips = sns.load_dataset("tips")
ax = sns.stripplot(x=tips["total_bill"])
ax = sns.stripplot(x="sex", y="total_bill", hue="day", data=tips, jitter=True)

在这种情况下,图例很小,每天显示不同的色调。但是,我想删除图例。

一般情况下,一个包含一个参数legend=False。但是,对于 stripplot,这似乎会输出一个属性错误:

AttributeError: Unknown property legend

可以删除 stripplots 的图例吗?如果是这样,如何做到这一点?

像这里一样使用ax.legend_.remove()

import seaborn as sns
import matplotlib.pylab as plt
sns.set_style("whitegrid")
tips = sns.load_dataset("tips")
ax = sns.stripplot(x="sex", y="total_bill", hue="day", data=tips, jitter=True)

# remove legend from axis 'ax'
ax.legend_.remove()

plt.show()