[英]How to plot array of coordinates on image using matplotlib?
我正在嘗試使用matplotlib繪制坐標數組。 x&y是具有x和y坐標的兩個數組。
樣本數據:
x = [489.99378204345703, 424.4607162475586, 665.4505157470703, 665.1176452636719]
y = [709.4012403488159, 253.38330745697021, 519.5582628250122, 519.5164632797241]
這是我用來繪制的代碼
im = plt.imread(p_transform_path)
implot = plt.imshow(im)
for p,q in zip(x,y):
x_cord = x[p]
y_cord = y[q]
plt.scatter([x_cord], [y_cord])
plt.show()
p_transform_path
是要在其上繪制坐標的圖像的路徑。
這是錯誤消息:
x_cord = x[p]
TypeError: list indices must be integers or slices, not numpy.float64
im = plt.imread(p_transform_path)
implot = plt.imshow(im)
for p,q in zip(x,y):
x_cord = p # try this change (p and q are already the coordinates)
y_cord = q
plt.scatter([x_cord], [y_cord])
plt.show()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.