Reputation: 529
Supposing I have a np.array like that:
data = np.array([[1,2],[2,4],[3,5],[4,5]])
I want to plot the path from the first point to the second then from the second to the third etc... How can I manage that. I know how to link all the point but not with a specifies order.
Upvotes: 5
Views: 12027
Reputation: 2956
import numpy as np
import matplotlib.pyplot as plt
data = np.array([[1,2],[2,4],[3,5],[4,5]])
plt.plot(data[:, 0], data[:, 1])
plt.show()
Alternatively, as suggested (this one by @fuglede is really nice):
plt.plot(*data.T)
Upvotes: 8