Python-有没有办法分离matplotlib图,以便继续计算?
发布于 2021-02-02 23:13:23
在Python解释器中执行以下指令后,将获得一个带有绘图的窗口:
from matplotlib.pyplot import *
plot([1,2,3])
show()
# other code
不幸的是,show()
当程序进行进一步的计算时,我不知道如何继续以交互方式探索创建的图形。
有可能吗?有时计算很长,如果可以在检查中间结果时进行计算,则将有所帮助。
关注者
0
被浏览
82
1 个回答
-
使用
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()