0

I want to plot a real-time graph in matplot lib with a limited number of X axis values (say 10).

My current graph does not do that and instead compresses the entire graph. When i get my 11th value, I want my 1st value to be wiped off. any ideas? I was thinking of using a cyclic queue, but do not know where and how to start.

My current code (dummy data) is:

for i in range(0,100):  #time
    time.sleep(0.1)
    for s in range(0,sensors):
        x[s].append(random.randint(20,80))
    drawnow(makePlot)
mooga
  • 3,136
  • 4
  • 23
  • 38
hsonal
  • 1
  • 2
  • Have you tried to adapt any of the methods you can find in [matplotlibs animation examples](https://matplotlib.org/examples/animation/index.html)? – Mr. T Jun 18 '18 at 06:51
  • A [circular buffer](https://stackoverflow.com/questions/4151320/efficient-circular-buffer) may be a good data structure to consider for your problem. –  Jul 01 '18 at 00:32

0 Answers0