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)
在你的笔记本里,试试
像这样单独调用,它应该在单独的窗口中提供输出。%matplotlib也有几个选项,具体取决于您的系统。要查看所有可用选项,请使用
呼叫
将再次在笔记本中绘制绘图。
您想在iPython控制台中键入
%matplotlib qt
。这只会更改您正在进行的会话。要在将来更改它,请转到Tools > Preferences
,选择iPython Console > Graphics
,然后将Graphics Backend
设置为Qt4
或Qt5
。这应该管用。另一个选项是使用plt。图:
(见:https://matplotlib.org/users/pyplot_tutorial.html)
相关问题 更多 >
编程相关推荐