0

Hi I'm trying to plot a random walk of n particles and I thought of using matplotlib.animate. If I have a known amount of lines I know how to do it, with line.set_data([], []), but how should I do it if I had a random or huge amount of particles?

Maybe there's another method. I thought of plt.scatter, but isn't that too slow?

dolefeast
  • 3
  • 2
  • Why not use a line formatted as bullet markers, `'ob', ms=6`, without connecting segments? Then you can use the mentioned `set_data` method to change the positions. – Lutz Lehmann Mar 31 '20 at 08:07
  • Sorry, I don't see how does that allow me to plot n trayectories. – dolefeast Mar 31 '20 at 08:10
  • You should probably more precise on how you intend the image to look and evolve. Perhaps demonstrate that in some fashion for the "known amount" case. How large are the steps, sub-pixel or multiple pixels? What is "huge", at what point is the amount of particles "random", does it change during the animation? – Lutz Lehmann Mar 31 '20 at 08:22
  • What I expect from my program is to show a simulation of n particles and see how does that system evolve. In physics terms what I want to see is the configuration space(I don't know if you use that term in coding), so what I see is the particles moving the same way I'd see them move if they weren't in a computer. By huge I meant having at least 60 particles. – dolefeast Mar 31 '20 at 08:28
  • Are you open to use other means than matplotlib? With some effort one can make good animations with pygame, like (structurally, the dynamic is somewhat off) in https://stackoverflow.com/questions/29374247/lennard-jones-potential-simulation for a molecule dynamic simulation. – Lutz Lehmann Mar 31 '20 at 08:56
  • Of course! I think this fits perfectly to what I'm trying to do. – dolefeast Mar 31 '20 at 09:13
  • I appended in my answer there my version of the corrected code, with anti-aliasing. – Lutz Lehmann Mar 31 '20 at 09:39

0 Answers0