Reputation: 503
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!!!
Upvotes: 0
Views: 247
Reputation: 57033
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)
Upvotes: 2