gpt4 book ai didi

python - 用户警告 : Patch object at has a label of '_K' which cannot be automatically added to the legend

转载 作者:行者123 更新时间:2023-12-05 03:50:10 25 4
gpt4 key购买 nike

使用 seaborn pairplot 绘图,之前曾使用不同的列作为 hue,但是在绘制 hue='letters' 列时,我收到用户警告并且无法绘制图例?我不确定为什么。

“字母”列的示例

letters
_J
_A
_H
_H
_L


fig = sns.pairplot(x_vars=x, y_vars=y, data=df, hue="letters", size=5, aspect=2.65)

figlegend = self.fig.legend(handles, labels, **kwargs)
/home/ec2-user/anaconda3/envs/chainer_p36/lib/python3.6/site-packages/seaborn/axisgrid.py:98: UserWarning: The handle <matplotlib.patches.Patch object at xxxxx has a label of '_H' which cannot be automatically added to the legend.

列中所有 _letters 的相同错误。

最佳答案

这是因为 matplotlib 开发人员选择忽略以 _ 开头的标签。

来自legend guide :

Those artists with an empty string as label or with a label starting with "_" will be ignored.

如果您想要图例,您应该创建一个新列,在其中去除下划线以用作 hue

关于python - 用户警告 : Patch object at has a label of '_K' which cannot be automatically added to the legend,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63595121/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com