UserWarning:位于的修补程序对象具有无法自动添加到图例中的“_K”标签

2024-05-20 17:33:33 发布

您现在位置:Python中文网/ 问答频道 /正文

使用seaborn pairplot打印,以前使用不同的列作为色调,但在打印色调=”字母”列时,我收到用户警告,它无法打印图例?我不知道为什么

“字母”列示例

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.

列中所有_字母的错误相同


Tags: 用户警告示例dfdata字母figvars
1条回答
网友
1楼 · 发布于 2024-05-20 17:33:33

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

legend guide开始:

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

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

相关问题 更多 >