python - returning results from matplotlib widget -


ok general problem have number of datasets, good, bad. want plot them use checkbuttons widget choose datasets. average these datasets , returned processed further , next load of data called.

essentially have 2 graphs callable g , f 1 2 axes (with data averaged) , second shows average of selected check boxes. need pause in code until happy data selection , have been trying use matplotlib button stop , return current average. struggling

    s1,s2=call.average()    #return average of checked lines     av1,=ax1.plot(x,s1)     av2,=ax1.plot(x,s2)     def func(label):         if call.d[label]==1:    #values d[label]==1 averaged, 0 ignored             call.d[label]=0         elif call.d[label]==0:             call.d[label]=1         # every time check box changed new average calculated , plotted         s1,s2=call.average()         av1.set_ydata(s1)         av2.set_ydata(s2)         f.canvas.draw()     def end(event):         return #from , outer function...      ##code check buttons     rax = g.add_axes([0.05, 0.3, 0.1, 0.3])     aq=append(call.s1.keys(),call.s2.keys())     check = checkbuttons(rax, aq, [true]*len(aq))     check.on_clicked(func)      ##code exit/save button     save = f.add_axes([0.75, 0.02, 0.05, 0.025])     sbutton = button(save, 'save')     sbutton.on_clicked(end)      show()      return s1,s2 #only return here after 'save' clicked  

i return when happy tick box selection , have clicked 'save' button.

i have tried while loop @ end of code before return figures appear no axes/data/buttons.

hopefully makes sense pasted middle of code. feels there simple solution have missed.

by not having interactive plotting on ioff() show() acts pause until figure closed , in def end(): can call close(f) , close(f) continue code returning current values s1 , s2.


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -