Ah, my bad. Try
self.legend.parent.transAxes.inverted().transform_point(loc_in_canvas) legend.parent points to the parent axes. -JJ On Wed, Mar 25, 2009 at 9:36 PM, C M <cmpyt...@gmail.com> wrote: > On Wed, Mar 25, 2009 at 9:06 PM, Jae-Joon Lee <lee.j.j...@gmail.com> wrote: >> 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 > > Thanks, but I am getting this error now: > > AttributeError: 'Legend' object has no attribute 'transAxes' > > My legend is created this way: > > self.legend = self.subplot.legend(self.line_collections_list, ['1'], > numpoints=1) > > And self.subplot is made this way: > > self.figure = Figure(None, dpi) > self.subplot = self.figure.add_subplot(111) > > I thought self.subplot is an Axes instance. Is it not? > > Thank you, > 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