相关疑难解决方法(0)

Seaborn countplot 为 x 值设置图例

我正在绘制分类数据和值计数 sns.countplot()

我正在尝试将 x 值的图例添加到图中,如下所示:句柄是 x 值的集合,标签是 x 值的描述。

ax = sns.countplot(x = df.GARAGE_DOM)
handles, labels = ax.get_legend_handles_labels()

handles = ["VP", "BC", "GC", "GP", "JC", "PO"]
labels = ["Voie Publique", "box", "Garage couvert", "garage particulier clos", "Jardin clos", "parking ouvert"]
by_label = OrderedDict(zip(handles,labels))
ax.legend(by_label.keys(), by_label.values())
Run Code Online (Sandbox Code Playgroud)

但是,我收到警告说

用户警告:

Legend 不支持“VP”实例。可以使用代理艺术家来代替。请参阅:http : //matplotlib.org/users/legend_guide.html#using-proxy-artist

我已经阅读了代理艺术家的文档,但在我的案例中没有找到示例。

在此处输入图片说明

谢谢你的帮助。

python matplotlib seaborn

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

matplotlib ×1

python ×1

seaborn ×1