这个问题在这里已经有了答案:
How to dynamically update a plot in a loop in Ipython notebook (within one cell)
(7 个回答)
5年前关闭。
在 ipython/jupyter notebook 中运行以下代码:
for i in range(4):
# any figure
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(range(i), range(i))
fig.show()
# do something that takes a long time:
a = fib(500000)
导致所有数字同时可见(在第 4 个循环之后)。
如何更改我的设置,以便数字在计算后立即可见(在 for 循环的下一步之前)?
注意我正在使用 %matplotlib 内联
最佳答案
一、导入显示:from IPython import display
并替换 fig.show()
来自 display.display(fig)
关于for-loop - 下一步之前的 Ipython notebook : show for-loop images "realtime",,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33613006/