Hi,

I'm plotting lines on top of an image using the plot command, trying to make
polygons. I click one point on an image and another point, and a line is
drawn between them. I'm also showing a guide line, so that the user can see
the line before pressing the mouse button.. All i'm doing is taking the last
point that the user clicked on and plot a line between that point and the
current point under the mouse cursor. New chosen points are appended to
nPolygonPointsX and Y. This works ok, but it's a bit slow.

my update connected to the motion_notify_event looks like this:

------------------------------------------------------------------------------
def onCursorUpdate(self, event)

x, y = event.xdata, event.ydata

a = self.fig.gca()

if len(self.nPolygonPointsX >= 1):
     guideLineX = [self.nPolygonPointsX[-1], x]
     guideLineY = [self.nPolygonPointsY[-1], y]

     # To avoid keeping guide lines when the cursor is moved:
     if len(a.lines) > 1:
         del(a.lines[-1])

     # Plot the guide line and update
     a.plot(guideLineX, guideLineY)
     self.canvas.draw()

------------------------------------------------------------------------------

Btw i'm running matplotlib with wxpython. So is there a faster way to update
this line plot? ..

Thanks!
Soren
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to