Michael Frauens
2008-02-12 17:07:21 UTC
I am using span selector to identify an area and then highlight in in green. I want the user to be able to validate this (or not) and then select another area (or not). However, when the user selects the alternate area I want the previous instance of axvspan to be deleted/removed. How do I remove this instance? of do I have to delete the whole plot and replot?
Removing the instance is strongly preferred becauase the user may of altered the display using the canvas widgets.
f=Figure(figsize=(12,8), dpi=72)
a=f.add_subplot(111)
...
a.plot(aTime, aDensity, 'k', aTime, aElec, 'b')
...
canvas = FigureCanvasTkAgg(f, master=root)
canvas.show()
canvas.get_tk_widget().pack(side=Tk.TOP)
.....
def onselect(timemin,timemax):
indmin,indmax=npy.searchsorted(glbl.act_time[glbl.newjob],(timemin,timemax))
indmax=min(len(glbl.act_time[glbl.newjob])-1,indmax)
thistime=glbl.act_time[glbl.newjob][indmin:indmax]
exec("thisDens=glbl.%s_d[%d][indmin:indmax]" % (newcolor, glbl.newjob))
exec("thisElect=glbl.%s_d[%d][indmin:indmax]" % (newcolor, glbl.newjob))
print thisDens
#creates a reference green area to validate area chosen
lo=glbl.act_time[glbl.newjob][indmin]
hi=glbl.act_time[glbl.newjob][indmax]
a.axvspan(lo,hi,facecolor='g',alpha=0.5)
canvas.show()
...
span=SpanSelector(a,onselect,'horizontal',useblit=True,
rectprops=dict(alpha=0.5,facecolor='red'))
____________________________________________________________________________________
Never miss a thing. Make Yahoo your home page.
http://www.yahoo.com/r/hs
Removing the instance is strongly preferred becauase the user may of altered the display using the canvas widgets.
f=Figure(figsize=(12,8), dpi=72)
a=f.add_subplot(111)
...
a.plot(aTime, aDensity, 'k', aTime, aElec, 'b')
...
canvas = FigureCanvasTkAgg(f, master=root)
canvas.show()
canvas.get_tk_widget().pack(side=Tk.TOP)
.....
def onselect(timemin,timemax):
indmin,indmax=npy.searchsorted(glbl.act_time[glbl.newjob],(timemin,timemax))
indmax=min(len(glbl.act_time[glbl.newjob])-1,indmax)
thistime=glbl.act_time[glbl.newjob][indmin:indmax]
exec("thisDens=glbl.%s_d[%d][indmin:indmax]" % (newcolor, glbl.newjob))
exec("thisElect=glbl.%s_d[%d][indmin:indmax]" % (newcolor, glbl.newjob))
print thisDens
#creates a reference green area to validate area chosen
lo=glbl.act_time[glbl.newjob][indmin]
hi=glbl.act_time[glbl.newjob][indmax]
a.axvspan(lo,hi,facecolor='g',alpha=0.5)
canvas.show()
...
span=SpanSelector(a,onselect,'horizontal',useblit=True,
rectprops=dict(alpha=0.5,facecolor='red'))
____________________________________________________________________________________
Never miss a thing. Make Yahoo your home page.
http://www.yahoo.com/r/hs