As I said in my previous email, the _loc attribute of the legend need to be in the normalized axes coordinate, i.e., the lower left corner of the axes being (0,0) and the upper-right corner being (1,1). Thus, it needs to be something like below.
loc_in_canvas = self.legend_x + mouse_diff_x, self.legend_y + mouse_diff_y loc_in_norm_axes = self.legend.transAxes.inverted().transform_point(loc_in_canvas) self.legend._loc = loc_in_norm_axes Note that it assumes that the parent of the legend is an Axes instance, which I think is your case. IHTH, -JJ On Wed, Mar 25, 2009 at 8:26 PM, C M <cmpyt...@gmail.com> wrote: > Ok, getting there. When I print the various coordinates to stdout, it > SHOULD be working, but my legend is simply disappearing. This > is the stdout on one pixel move with the mouse in the x: > > mouse x position at pick time 489 > mouse y position at pick time 349.0 > Legend x position at pick time = 445.878125 > Legend y position at pick time= 339.8 > motion_event.x = 488 > motion_event.y = 349.0 > mouse moved x = 1 > mouse moved y = 0.0 > new legend location on move = (446.87812499999995, 339.80000000000001) > release > > But what instead happens is the legend poofs out of existence. > > At the end of the motion event, I am calling this: > > self.canvas.draw() > self.parent.Refresh() > > And wonder if I should be using some other way to redraw the legend? > Is it just not being redrawn this way? I thought I should use self.draw(), > which is a method in my class which draws the line and the legend, > but using that does nothing at all. > > Very stuck here. Any help appreciated. > C > > ------------------------------------------------------------------------------ > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > ------------------------------------------------------------------------------ _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users