在python中修改xarray绘图图例

2024-04-24 14:55:24 发布

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

我不熟悉使用xarray的绘图功能,我通常使用matplotlib

我正在尝试移动xarray.plot.scatter创建的图例。能够删除图例标题也很酷

data.plot.scatter(x = 'HGT', y = var, hue = 'time', add_guide = True)

enter image description here

如果我通过ax.legend创建一个单独的图例,当add_guide=False时,我的图例顺序就会混乱。我的绘图是用不同的颜色标记不同的小时对(hours2-hours1),为了便于理解,顺序非常重要

ax.legend(labels, bbox_to_anchor=(-1.15, 2.4, -1., .102), loc='lower left', ncol = 6)

enter image description here

因此,我试图更好地理解如何修改图例xarray.plot.scatter,到目前为止,我很难找到有关它的信息。有什么建议吗?:)


Tags: 功能add绘图标题dataplot顺序matplotlib