在Python解释器中执行这些指令后,会出现一个带有绘图的窗口:
from matplotlib.pyplot import *
plot([1,2,3])
show()
# other code
不幸的是,当程序做进一步的计算时,我不知道如何继续交互地探索show()
创建的数字.
有可能吗?有时计算很长,如果在判断中间结果的过程中继续计算,会有所帮助.
在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()