【发布时间】:2021-04-10 13:00:27
【问题描述】:
我不明白我在这里做错了什么。我想将图例中的 0 和 1 更改为“零”和“一”,但不知何故这也会改变图例中的颜色。
这是我得到第一张照片的方式:
sns.scatterplot(ax = axes, data = data_pcoa, x = "Coordinate 0",
y = "Coordinate 1", hue = "Number", palette = ["orange", "blue"])
axes.set(xlabel = "1st PCo", ylabel = "2nd PCo")
axes.legend()
这就是我获得第二张图片的方式:
sns.scatterplot(ax = axes, data = data_pcoa, x = "Coordinate 0",
y = "Coordinate 1", hue = "Number", palette = ["orange", "blue"])
axes.set(xlabel = "1st PCo", ylabel = "2nd PCo")
axes.legend(labels = ['zero', 'one'])
如您所见,在第二张图片中,图例标题已更改,但颜色不再与情节匹配。
【问题讨论】:
标签: python matplotlib colors legend