【发布时间】:2014-10-18 11:31:06
【问题描述】:
我在交互模式下使用 matplotlib 向用户显示一个绘图,这将帮助他们输入一系列变量。他们可以选择点击“?”显示此图,然后将重复提示变量。
如果它仍在显示,我怎么知道不要重新绘制该图?
从表面上看,我有这个笨拙(伪)的代码:
answer = None
done_plot = False
while answer == None:
answer = get_answer()
if answer == '?':
if done_plot:
have_closed = True
##user's already requested a plot - has s/he closed it?
## some check here needed:
have_closed = ?????
if have_closed == False:
print 'You already have the plot on display, will not re-draw'
answer = None
continue
plt.ion()
fig = plt.figure()
### plotting stuff
done_plot = True
answer = None
else:
###have an answer from the user...
我可以使用什么(根据 plt.gca()、fig 等...)来确定是否需要重新绘制?有没有我可以检查的状态?
非常感谢,
大卫
【问题讨论】:
-
认为问题需要更加清晰。您是否跟踪他们打开的数字?可以同时打开多个图形还是只打开一个图形?
标签: python matplotlib