2017-04-17 7 views
-1

Ich versuche einige Plots mit plt.show() darzustellen. Ich bekomme die Plots auf der IPython-Konsole, aber ich muss jede Figur in einem neuen Fenster sehen. Was kann ich tun ?plt.show() öffnet kein neues Zahlenfenster

+0

Bitte klären. Möchten Sie, dass alle Fenster mit den Plots gleichzeitig geöffnet sind? Oder möchten Sie nur jedes Diagramm in einem Fenster statt in der IPython-Konsole? –

+0

Ich möchte jedes Diagramm ein separates Fenster sehen, nicht in der IPython-Konsole. – ufdul

+0

weil ich sie später speichern muss mit figures = [manager.canvas.figure für manager in matplotlib._pylab_helpers.Gcf.get_all_fig_managers()] Ich brauche alle Figuren, um jedes Diagramm in einem separaten Figurenfenster zu öffnen – ufdul

Antwort

0

Sie möchten %matplotlib qt in Ihre iPython-Konsole eingeben. Dies ändert es für die Sitzung, in der Sie sich befinden. Um es für die Zukunft zu ändern, gehen Sie Tools > Preferences, wählen Sie iPython Console > Graphics, dann setzen Sie Graphics Backend auf Qt4 oder Qt5. Dies sollte funktionieren.

1

In Ihrem Notebook, versuchen

import matplotlib.pyplot as plt 
    %matplotlib 

allein so aufgerufen, sollte es Ausgabe in einem separaten Fenster geben. Je nach System gibt es auch mehrere Optionen für% matplotlib. Um zu sehen, Sie alle Optionen zur Verfügung, verwenden

%matplotlib -l 

Aufruf

%matplotlib inline 

werden die Parzellen im Notebook ziehen wieder.

0

Andere Option ist mit 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) 

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

Verwandte Themen