0

I hope you're doing well. I've been working on a car simulation project and would love to create a visualization for it. So far, I've been able to plot the positions of cars in a single lane using matplotlib for each time interval sample plot of car locations. Here's the code I have to get one such plot:

data_points, data_plot = simulation.run_simulate()
plt.plot(data_plot[200], np.ones(data_plot[200].shape[0]), linewidth=0, marker='.', markersize=5)
plt.show()

(Please disregard the axes coords; they're not super relevant). In the above code, I chose an arbitrary time step (200 seconds into the simulation, in this case) to visualize, where each dot represents a car. Since I have around 1000 time steps, what I would like to do is iterate through data_plots, plotting each time interval from 0 to 999, and add all those plots together to create some kind of animation.

Essentially, is there a way I can make and put together 1000 matplotlib plots into a single continuous animation/video without downloading each individual plot first?

Thanks for your time :)!

Trenton McKinney
  • 43,885
  • 25
  • 111
  • 113
bg10
  • 1
  • SO is not a coding service. Please read the following documentation, then [edit], and rephrase the question. [Take the Tour](https://stackoverflow.com/tour), [How to ask a good question](https://stackoverflow.com/help/how-to-ask), & [On Topic](https://stackoverflow.com/help/on-topic). Always provide a [mre] with **code, data, errors, current & expected output, as [formatted text](https://stackoverflow.com/help/formatting)** & you're expected to [try to solve the problem first](https://meta.stackoverflow.com/questions/261592). – Trenton McKinney Aug 07 '21 at 20:14

0 Answers0