Can i have multiple matplotlib graphical windows in python interactive mode?

I have been using Matlab / Octave for a long time and I am switching to NumPy / SciPy. I find that matplotlib is very similar to drawing a picture in Matlab, and it is easy to use.

But, one thing, I’m not happy with matplotlib, when I draw a shape using plt.show(), then the process is stuck there, so I can’t enter new commands and not start another window to draw another shape before closing this window. For example, if we enter the following code, then before closing this window we cannot enter a new command and do not start another window for another chart.

import matplotlib.pyplot as plt
plt.plot([1,2,3,4])
plt.ylabel('some numbers')
plt.show()

This behavior is very different from the Matlab schedule. In Matlab interactive mode, we can have several curly windows.

Can we do the same in python interactive mode?

+4
source share
2 answers

At startup, IPython % matplotlib supports interactive matplotlib support without importing anything into the interactive namespace. Then running plt.figure () immediately opens a new chart window, plt.imshow () fills it with an image, and plt.plot () does the same for tabular data, without blocking console interactivity.

Thanks to the matplotlib interactive mode, its ok runs plt.show (), and it won’t block anything even without setting block = False, which causes IPython to hang in non-interactive mode.

% pylab matplotlib, .

, <% run -i ' IPython , .

matplotlib . ? mathplotlib IPython.

+4

, plt.ion() plt.show().

+3

All Articles