plt.show()不会打开一个新的数字窗口
答
您想在您的iPython控制台中输入%matplotlib qt
。这会改变它仅适用于您所处的会话。要改变它的未来,去Tools > Preferences
,选择iPython Console > Graphics
,然后将Graphics Backend
设置为Qt4
或Qt5
。这应该工作。
答
在你的笔记本,尝试
import matplotlib.pyplot as plt
%matplotlib
单独调用这个样子,也应该给输出在单独的窗口。根据您的系统,还有几个选项可用于%matplotlib。要查看所有可用选项,使用
%matplotlib -l
调用
%matplotlib inline
将再次绘制在笔记本的地块。
答
另一种选择是使用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)
请澄清。你想同时打开所有包含图的窗口吗?或者你只是想让每个图表在一个窗口中而不是在IPython控制台中? –
我想看到每个图是一个单独的窗口,而不是在IPython控制台中。 – ufdul
,因为我需要在matplotlib._pylab_helpers.Gcf.get_all_fig_managers()中使用figure = [manager.canvas.figure for manager]来保存它们,我需要在一个单独的数字窗口中打开每个图的所有数字 – ufdul