【发布时间】:2014-05-19 15:30:47
【问题描述】:
本页讨论使用 ipython 进行交互式绘图:http://matplotlib.org/users/shell.html
根据该页面,默认情况下,用于在 ipython 中运行脚本的 %run 命令会关闭交互模式。是否也可以选择以交互模式运行脚本?
我希望脚本中的绘图命令在运行后立即在绘图图中生效,就像从控制台交互式输入一样。
例如,考虑以下非常简单的脚本:
# try.py:
# run in ipython that is started with
# ipython --pylab
# using
# %run -i try.py
from numpy import *
from time import sleep
ion()
x = randn(10000)
hist(x,100)
show()
sleep(5)
xlabel('labalu')
当按照注释中的指示从 ipython 运行时,此脚本会等待 5 秒,然后显示所有内容。我想要的是:从 ipython 运行时,如注释中所示,脚本应立即显示直方图,等待 5 秒,然后更新图形以显示 x 标签。
【问题讨论】:
标签: python matplotlib ipython