matplotlib inline 在所有文本之后绘制所有图形
matplotlib inline plots all figures after all text
在 jupyter notebook 中,启用 %matplotlib inline
后,既打印文本又绘制图形的单元格的输出将在显示图形之前先显示全部文本。即使在打印文本之前生成图形(并调用 show() on)也会发生这种情况。
例如:
fig = plt.figure()
fig.add_subplot(111)
fig.show()
print "hello"
会显示空图前的'hello'。
如何解决这个问题,使每个图形都真正内联显示?
我想你想明确地 display
这个数字,使用 IPython 的显示功能:
from IPython.display import display
fig = plt.figure()
fig.add_subplot(111)
display(fig)
print("hello")
在 jupyter notebook 中,启用 %matplotlib inline
后,既打印文本又绘制图形的单元格的输出将在显示图形之前先显示全部文本。即使在打印文本之前生成图形(并调用 show() on)也会发生这种情况。
例如:
fig = plt.figure()
fig.add_subplot(111)
fig.show()
print "hello"
会显示空图前的'hello'。
如何解决这个问题,使每个图形都真正内联显示?
我想你想明确地 display
这个数字,使用 IPython 的显示功能:
from IPython.display import display
fig = plt.figure()
fig.add_subplot(111)
display(fig)
print("hello")