在Python解释器中执行这些指令后,会出现一个带有绘图的窗口:

from matplotlib.pyplot import *
plot([1,2,3])
show()
# other code

不幸的是,当程序做进一步的计算时,我不知道如何继续交互地探索show()创建的数字.

有可能吗?有时计算很长,如果在判断中间结果的过程中继续计算,会有所帮助.

推荐答案

使用matplotlib个不会阻塞的呼叫:

使用draw():

from matplotlib.pyplot import plot, draw, show
plot([1,2,3])
draw()
print('continue computation')

# at the end call show to ensure window won't close.
show()

使用交互模式:

from matplotlib.pyplot import plot, ion, show
ion() # enables interactive mode
plot([1,2,3]) # result shows immediatelly (implicit draw())

print('continue computation')

# at the end call show to ensure window won't close.
show()

Python相关问答推荐

在pandas DataFrame上运行apply()时如何访问DateTime索引?

手动为pandas中的列上色

使用Curses for Python保存和恢复终端窗口内容

KNN分类器中的GridSearchCV

"Discord机器人中缺少所需的位置参数ctx

Python:记录而不是在文件中写入询问在多文件项目中记录的最佳实践

过载功能是否包含Support Int而不是Support Int?

如何根据情况丢弃大Pandas 的前n行,使大Pandas 的其余部分完好无损

使用Keras的线性回归参数估计

如何在msgraph.GraphServiceClient上进行身份验证?

将特定列信息移动到当前行下的新行

仿制药的类型铸造

. str.替换pandas.series的方法未按预期工作

通过Selenium从页面获取所有H2元素

如何访问所有文件,例如环境变量

isinstance()在使用dill.dump和dill.load后,对列表中包含的对象失败

我的字符串搜索算法的平均时间复杂度和最坏时间复杂度是多少?

在matplotlib中删除子图之间的间隙_mosaic

为什么常规操作不以其就地对应操作为基础?

如何找出Pandas 图中的连续空值(NaN)?