1

我已经搜索了一段时间,但找不到一个好的答案。

如何在绘图上指定标签框的位置,使其不会遮挡线条?

例如:我制作的这个情节中的标签框挡住了线条

在此处输入图像描述

def savePlt(tCoords, yCoords, perturbedYCoords1, perturbedYCoords2):
plt.plot(tCoords, yCoords, 'co', label="(t, y*)")
plt.plot(tCoords, perturbedYCoords1, 'yo', label="(t, y1)")
plt.plot(tCoords, perturbedYCoords2, 'ko', label="(t, y2)")
plt.legend()    

plt.hold(False)
plt.savefig("cheezberger")
return
4

1 回答 1

8

假设您正在使用图例...当您调用它时,请使用 loc 关键字。例如

legend(loc=1)

loc=1 将图例放在右上角。以下是位置/数字配对:

右上角:1;左上:2;左下:3;右下:4;对:5;左中:6;中右:7;下中心:8;上中心:9;中心:10;

链接: http: //matplotlib.org/users/legend_guide.html

于 2013-11-08T02:24:16.127 回答