i trying write code refreshing plot in gui, every time instead of refreshing plot in juts plots next graph n different location.
if tumortypeplot== 'atypical teratoid rhabdoid tumour': f = figure(figsize=(7.5,5), dpi=100) f.gca().invert_xaxis() = f.add_subplot(111) if var1.get()==1: a.errorbar(ppm, atrtave_pf, atrtsd_pf, linestyle='-', ecolor='g', marker='^') a.set_title('atypical teratoid - rhabdoid tumour_ posterior fossa') a.set_xlabel('frequency/ppm') a.set_ylabel('intensity (au)') elif var2.get()==1: a.errorbar(ppm, atrtave_sp, atrtsd_sp, linestyle='-', ecolor='g', marker='^') a.set_title('atypical teratoid - rhabdoid tumour_ supratentorial') a.set_xlabel('frequency/ppm') a.set_ylabel('intensity (au)') canvas = figurecanvastkagg(f, master=root) canvas.show() canvas.get_tk_widget().pack(side="right") i tried using a.clf() or a.clear(). doesn't work. have started using python , appropriate find out problem code.
as a axis object, doesn't have clear figure clf method. should raise error, may hidden try statement? clear current axis, need call a.cla() (or a.clear()). can call new plot command should replace axis on current figure.
for gui, if doesn't work, can clear figure f.clf() , entirely replace new plot. note in wxpython, part of gui need use f.clf(keep_observers=true) , readd subplot, etc a=f.add_subplot(111) correct result.
the fastest option, complicated errorbar, contains number of objects, update data in returned handle errorbar function , redraw. like,
eb = a.errorbar(ppm, atrtave_pf, atrtsd_pf, linestyle='-', ecolor='g', marker='^') then when you've updated ppm , atrtave_pf , want update lines,
line=eb.line[0] line.set_data(ppm, atrtave_pf) f.canvas.draw() although may have update errorbars in eb manually , may more hassle it's worth.
Comments
Post a Comment