8
我跟着文檔,但仍未能標出一行。如何在matplotlib(python)中標記一行?
plt.plot([min(np.array(positions)[:,0]), max(np.array(positions)[:,0])], [0,0], color='k', label='East') # West-East
plt.plot([0,0], [min(np.array(positions)[:,1]), max(np.array(positions)[:,1])], color='k', label='North') # South-North
在上面的代碼片段中,我試圖繪製出北方向和東方向。
position
包含要繪製的點。
但我結束了2條直線,沒有標籤如下:
哪裏出了問題?
據我所知標籤參數是爲圖例。你可能想看看這個註釋:http://matplotlib.org/users/annotations_intro.html - 放入一個plt.legend(),你會看到標籤打開。 – shaunakde