我有一个函数调用draw。我有 2 个列表,一个带有 x 坐标,第二个带有 y 坐标。我正在制作一个情节,我想在情节中写下 x,y 坐标。我看到注释可能是答案,但它无法获得列表。我正在尝试这样做:
def draw(LuxCoordinates, finalPix, verName, GraphNum):
xy = (LuxCoordinates,finalPix)
plt.axes([0.1, 0.1, 0.6, 0.8]);
plt.xlim(0,3100,);
plt.ylim(0,100,100);
plt.xticks(arange(0,3500,350)) #spaces of x axis
plt.yticks(arange(0,100,10)) #spaces of y axis
if GraphNum == 1:
plt.plot(LuxCoordinates, finalPix, 'r', label=verName);
if GraphNum == 2:
plt.plot(LuxCoordinates, finalPix, 'g', label=verName);
if GraphNum == 3:
plt.plot(LuxCoordinates, finalPix, 'b', label=verName);
legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)
plt.scatter(LuxCoordinates, finalPix, linewidths=1)
**for i, txt in enumerate(xy):
plt.annotate(txt, (LuxCoordinates[i],finalPix[i]))**
plt.grid(axis)
plt.xlabel('Ambient', color='r');
plt.ylabel('Depth Grows', color='r'); # grayscale color
plt.title(PngName, color='b');
savefig(PngName+'_'+date+'_'+currentime+'.png')
但我得到了这个:
放大:
你可以看到它写了一些东西,但它是第一个点上的所有列表,我希望每个 x,y 将分别写在该点附近,所以蓝色图中的第一个点将是 0,96.6 , 在绿色中它将是 0, 93.54 (你可以看到 2 个列表)
有人可以帮我吗?谢谢!