Abruzzo Forte e Gentile Abruzzo Forte e Gentile - 11 months ago 73
Python Question

plotting lines without blocking execution

I am using matplotlib to draw charts and graphs.

When I plot the chart using the command

my code blocks at this command.

I would like to refresh my list of values with new data , and than refresh the image on the background. How to do that without closing each time the window with the graph?
Below is the code I am using

import pylab
a = (1,2,3,4)
pylab.show() # blocks here


In IPython started with -pylab it should not block.

Otherwise: With ion() you turn the interactive mode on. show() does not block your system anymore. Every draw() or plot(x, y) updated your plot.

ioff() turns interactive mode off. Useful if you add lots of data and don't want to update every little detail.

See also: http://www.scipy.org/Cookbook/Matplotlib/Animations