From: avee <av...@bl...> - 2009-12-07 15:07:26
|
andreyd wrote: > > > This worked for me: > to remove axis temporary and than to take background of the whole picture > but without ticks and labels of this axis: > > This suggestion did not resolve the problem. But here is the solution. I have no idea why the first version is not working. I changed the threading technique: - from gobject.idle_add(run) to the fig.canvas.mpl_connect('draw_event', start_anim) I think it can be only that... Any ideas? import matplotlib matplotlib.use('GTKAgg') from pylab import figure, show import gobject, gtk import time fig = figure() ax = fig.add_subplot(111) ax.set_xlim(0, 30) #fig.subplots_adjust(left=0.3, bottom=0.3) # check for flipy bugs ax.grid() # to ensure proper background restore ax.get_xaxis().set_animated(True) fig.canvas.draw() def run(): if run.background is None: run.background = fig.canvas.copy_from_bbox(fig.bbox) fig.canvas.restore_region(run.background) i = run.cnt ax.set_xlim(0+i,30+i) fig.draw_artist(ax.get_xaxis()) fig.canvas.blit() if run.cnt == 180: gtk.main_quit() raise SystemExit run.cnt += 1 time.sleep(0.1) return True def start_anim(event): gobject.idle_add(run) fig.canvas.mpl_disconnect(start_anim.cid) start_anim.cid = fig.canvas.mpl_connect('draw_event', start_anim) run.background = None run.cnt = 0 show() -- View this message in context: http://old.nabble.com/animated-axis-tp26635860p26678529.html Sent from the matplotlib - users mailing list archive at Nabble.com. |