I'd like to have the matplotlib "show" command return to the command line while displaying the plot. Most other plot packages, like R, do this. But pylab hangs until the plot window closes. For example:
import pylab
x = pylab.arange( 0, 10, 0.1)
y = pylab.sin(x)
pylab.plot(x,y, 'ro-')
pylab.show() # Python hangs here until the plot window is closed
I'd like to be able to view the plot while doing command line queries. I'm running Debian squeeze with python 2.6.6. My ~/.matplotlib/matplotlibrc contains
backend : GTKAgg
Thanks!
Answer #6: plt. show() and plt. draw() are unnecessary and / or blocking in one way or the other.
Matplotlib is used in a IPython shell or a notebook (ex: Kaggle), plt. show() is unnecessary.
PyLab is a procedural interface to the Matplotlib object-oriented plotting library. Matplotlib is the whole package; matplotlib. pyplot is a module in Matplotlib; and PyLab is a module that gets installed alongside Matplotlib. PyLab is a convenience module that bulk imports matplotlib.
In the current versions of the IPython notebook and jupyter notebook, it is not necessary to use the %matplotlib inline function. As, whether you call matplotlib. pyplot. show() function or not, the graph output will be displayed in any case.
Add pylab.ion()
(interactive mode) before the pylab.show()
call. That will make the UI run in a separate thread and the call to show
will return immediately.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With