Reputation: 7906
I love Matplotlib but sometimes the lack of 'idiots guide' examples is infuriating.
Long story short, I have several large lists of XYZ positional data from simulated motion throw 3D space from multiple entities. I currently do this statically, i.e.
for entity in entities:
x=map(itemgetter(0),positionLog(entity))
y=map(itemgetter(1),positionLog(entity))
z=map(itemgetter(2),positionLog(entity))
ax.plot(x,y,z,label=nameLookup(entity))
plt.show()
What I'd like to do is to have these lists 'step' out, i.e where all the entities are at t(0), then add in the t(1) points and so on.
However, it's not clear in any of the examples I've found how to accomplish this. The examples that I see show how to do individual runs, i.e. for one entity, but I can't see how to do all (N) in lock-step.
Suggestions please? :D
Upvotes: 1
Views: 1639
Reputation: 6149
So one way to do what I think you want is to make x, y, and z lists. add t(0) to the plot and show the plot. Next, append t(1) to you original x, y, z lists, update the plot with the new x, y, z coordinates, then refresh the plot (which is the old way of doing animations in matplotlib).
This example: http://matplotlib.sourceforge.net/examples/animation/basic_example.html uses the built in animation function to generate an animation the new way, which is exactly what I think you want, just add your third coordinate.
Upvotes: 1