更新时间:2023-11-24 08:57:16
据我所知,一旦它开始在该进程中运行另一个脚本,就没有简单的方法来连接到现有的python进程.
As far as I know there is no easy way to connect to an existing python process once it is started to run another script within this process.
您可以选择在交互式会话中工作,例如在IPython中.在那里你可以创建你的情节并在你前进时对其进行操纵.
The option you have is to work in an interactive session, e.g. within IPython. There you may create your plot and manipulate it as you advance.
例如
1: import matplotlib.pyplot as plt
2: import numpy as np
3: fig, ax = plt.subplots()
4: line, = ax.plot([1,3,2])
5: plt.ion()
6: plt.show() # shows the figure
7: line2, = plt.plot([2,2,1]) # inside the figure shows another line
8: line.remove() # removes the first line from the figure