4
votes

I am trying to show some plots using plt.show (). i get the plots shown on the IPython console, but I need to see each figure in a new window. What can I do ?

3
Please clarify. Do you want all the windows containing the plots open at the same time? Or do you just want each plot in a window rather than in the IPython console?Rory Daulton
I want to see each plot an a seperate window, not in the IPython console.ufdul
because I need to save them later on using figures=[manager.canvas.figure for manager in matplotlib._pylab_helpers.Gcf.get_all_fig_managers()] I need all the figures to be open each plot in a seperate figure windowufdul

3 Answers

5
votes

In your notebook, try

    import matplotlib.pyplot as plt
    %matplotlib

Called alone like this, it should give output in a separate window. There are also several options to %matplotlib depending on your system. To see all options available to you, use

    %matplotlib -l

Calling

    %matplotlib inline

will draw the plots in the notebook again.

4
votes

You want to type %matplotlib qt into your iPython console. This changes it for the session you're in only. To change it for the future, go Tools > Preferences, select iPython Console > Graphics, then set Graphics Backend to Qt4 or Qt5. This ought to work.

0
votes

Other option is using plt.figure:

import matplotlib.pyplot as plt
plt.figure(1)                # the first figure
plt.subplot(211)             # the first subplot in the first figure
plt.plot([1, 2, 3])
plt.subplot(212)             # the second subplot in the first figure
plt.plot([4, 5, 6])
plt.show(block=False)

plt.figure(2)                # a second figure
plt.plot([4, 5, 6])          # creates a subplot(111) by default
plt.show(block=False)

plt.figure(1)                # figure 1 current; subplot(212) still current
plt.subplot(211)             # make subplot(211) in figure1 current
plt.title('Easy as 1, 2, 3') # subplot 211 title
plt.show(block=False)

(see: https://matplotlib.org/users/pyplot_tutorial.html)