0

I would like to plot many points on a figure. The method I use is:

main_ax.plot(10, 20, '.w')

This code can help me polt a point at (10, 20)

But I need to plot many points:

data = [(13, 45), (13, 46), (13, 47), (13, 48), (13, 49), (13, 50), (13, 51), (13, 52), (13, 53), (13, 54), (14, 40), (14, 41), (14, 42), (14, 43), (14, 44), (14, 55), (14, 56), (14, 57), (14, 58), (14, 59), (15, 37), (15, 38), (15, 39), (15, 60), (15, 61), (15, 62), (16, 35)]

The only way that I know to plot these points is:

main_ax.plot(13, 45, '.w')
main_ax.plot(13, 46, '.w')
main_ax.plot(13, 47, '.w')
main_ax.plot(13, 48, '.w')........

Is there any other faster method that I can plot many points?

Thanks!!!

1 Answer 1

2

You can split your data into two lists of x and y coordinates and do a scatter plot:

x, y = zip(*data)
plt.scatter(x, y)

enter image description here

Sign up to request clarification or add additional context in comments.

1 Comment

As an alternative, you can also use plt.plot(x, y, 'o')

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.