Reputation: 63
I have 2-D co-ordinates of each point in a trajectory for multiple trajectories. I want to plot all these trajectories on a single plot using python preferably matplotlib. I want the time-series plot of the trajectories as in the left figures in sample figures. The sample figure I found on Internet is
Upvotes: 1
Views: 3880
Reputation: 1207
Use the pyplot.plot() method. You can plot an arbitrary number of trajectories on the same figure.
from matplotlib import pyplot
x = range(12)
y1 = range(12)
y2 = [i**2 for i in x]
# y3,y4,...yn
pyplot.plot(x,y1)
pyplot.plot(x,y2)
pyplot.show()
For 3D plots:
from matplotlib import pyplot
from mpl_toolkits.mplot3d import Axes3D
x = range(12)
y1 = range(12)
y2 = [i**2 for i in x]
z1 = range(12)
z2 = [i/2 for i in z1]
f = pyplot.figure()
ax = f.add_subplot(111, projection='3d')
ax.set_xlabel('x (cm)')
ax.set_ylabel('y (cm)')
ax.set_zlabel('time(frame)')
ax.plot(x,y1,z1)
ax.plot(x,y2,z2)
pyplot.show()
Upvotes: 1