2

I'm trying to plot the movement of many particles with periodic boundary conditions. I want to plot their trajectory for the last 10 timesteps.

This is my plot code so far (X is a matrix, each column is a different particle and each row is a different time, that gives me each x coordinate at each time; same goes for Y):

plt.figure()
plt.figure(figsize=(12,11))
plt.grid(True)

plt.plot(X[time_steps-10:],Y[time_steps-10:],'k-')
plt.show()

But I'm having a problem with the plot because, since I'm using lines '-' when the particle leaves one wall and reappears in the other I have a line connecting those two postions that I don't want:

enter image description here

ImportanceOfBeingErnest
  • 321,279
  • 53
  • 665
  • 712
  • I guess you need to solve this on the level where you create that matrix, but that is not shown in the question, so it's close to impossible to help here. – ImportanceOfBeingErnest May 23 '18 at 11:17
  • You could split your matrices where the difference between two positions is greater than 6 (almost your domain) – Jonas May 23 '18 at 12:06

0 Answers0