1

I'm trying to plot an array of coordinates using matplotlib. x & y are two arrays with x and y coordinates.
Sample Data:

x = [489.99378204345703, 424.4607162475586, 665.4505157470703, 665.1176452636719]

y = [709.4012403488159, 253.38330745697021, 519.5582628250122, 519.5164632797241]

This is the code I'm using to plot

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 is the path of the image on which I'm plotting the coordinates.

This is the error message:

x_cord = x[p]
TypeError: list indices must be integers or slices, not numpy.float64

1 Answer 1

4
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()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.