4

我正在尝试使用 plt.show () 显示一些图。我得到了 IPython 控制台上显示的图,但我需要在新窗口中查看每个图。我能做些什么 ?

4

3 回答 3

5

在你的笔记本中,尝试

    import matplotlib.pyplot as plt
    %matplotlib

像这样单独调用,它应该在单独的窗口中提供输出。%matplotlib 也有几个选项,具体取决于您的系统。要查看所有可用的选项,请使用

    %matplotlib -l

打电话

    %matplotlib inline

将再次在笔记本中绘制绘图。

于 2017-04-17T10:14:39.560 回答
4

你想在%matplotlib qt你的 iPython 控制台中输入。这仅会更改您所在的会话。要为将来更改它,请转到Tools > Preferences,选择iPython Console > Graphics,然后设置Graphics BackendQt4Qt5。这应该行得通。

于 2017-04-17T10:07:33.950 回答
0

其他选项是使用 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)

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

于 2017-09-21T08:26:19.793 回答