Friday 15 May 2015

python - How to continuously update pyplot figure -


I am trying to create a GUI that will update a matplotib plot with continuous data gathering. I would like to plot the last 5 data points and place some space in front of the most recent data point

Here is a very simplified version of my script which explains what's my problem: import import paleab.ion () x1 = [0, 1,2,3,4,5] x2 = [5,6,7,8,9,10] Y1 = [5,6,7,8,7,8] y2 = [8,7,6, 5,4,3] rate = 1 timer = 0 count = 0 while calculation & lt; 2: if timer == 0: pylab.plot (x1, y1) pylab.show () timer + = rate calculation + 1 time sleep (1) other: pylab.plot (x2, y2) pylab.draw () timer + = Rate calculation + = 1 time.sleep (1)

I have already tried to use the show (block = false) and some other things what code to continue Can this force be forced to remain open for use and command I can use to update it? Any other suggestions would be greatly appreciated.

The following sequence worked for me ..

  • Ion () -
  • To show ()
  • To show

    Update the graph - Plot () - Draw () - Instead show ( )

No comments:

Post a Comment