Hi,
I kind of got the basic functionality working using
cid = self.fig.canvas.mpl_connect('motion_notify_event',
self.update_marker)
def update_marker(self, event):
print "plotMarker()" # DEBUG
self.marker=self.ax1
#print 'button=%d, x=%d, y=%d, xdata=%f, ydata=%f'%(
# event.button, event.x, event.y, event.xdata, event.ydata)
# DEBUG
self.ax1.axvline(x=event.xdata, linewidth=1, color='r')
self.canvas.draw() # redraw
but I still have the problem that previous lines still appear on the
plot.
Also, canvas.draw() seems to be a bit of a performance hog. Does anyone
have
any more sophisticated solution to this?
Cheers,
Sven
Use draw_idle() if performance is an issue. Also, you don’t have to redraw everything. You can save the object returned by avline() and in subsequent draws, just modify the data. Usually, there is a set_data() or a set_xy() method you can use for this.
Ben Root
···
On Tuesday, December 6, 2011, Sven Duscha <duscha@…3034…> wrote:
Hi,
I kind of got the basic functionality working using
cid = self.fig.canvas.mpl_connect('motion_notify_event',
self.update_marker)
def update_marker(self, event):
print “plotMarker()” # DEBUG
self.marker=self.ax1
#print 'button=%d, x=%d, y=%d, xdata=%f, ydata=%f'%(
# event.button, event.x, event.y, event.xdata, event.ydata)
DEBUG
self.ax1.axvline(x=event.xdata, linewidth=1, color='r')
self.canvas.draw() # redraw
but I still have the problem that previous lines still appear on the
plot.
Also, canvas.draw() seems to be a bit of a performance hog. Does anyone
have
any more sophisticated solution to this?
Cheers,
Sven