Hi Che, I think you got bit by the "reply to list" non-feature of this list...

>> In ours, we catch the mpl button down event and after establishing a
>> hit on the legend do:
>
> I was using the pick event, not the button down event.  How do you
> "establish a hit on the legend" in the button down event handler?

So, keep in mind that we're using 0.90.1. This was before the nice
hit-test routines. We wrote our own hit-test routines loosely based
around the "object_picker.py" demo that was current at the time.

>>            bbox = self._legend.get_window_extent()
>>            self._dragOffset = (bbox.xmin() - mplEvent.x, bbox.ymin()
>> - mplEvent.y)
>>
>> Then in the mousemove event handler we do:
>>
>>            self._moveLegend(mplEvent.x + self._dragOffset[0],
>> mplEvent.y + self._dragOffset[1])
>>
>> where self._moveLegend is:
>>
>>    def _moveLegend(self, x, y, autoDraw=True):
>
> What is the purpose of autoDraw = True?

This is something we carry around in our application to limit the
number of redraws to reduce flicker.

>>        height = float(self.figure.bbox.height())
>>        width = float(self.figure.bbox.width())
>
> Can someone confirm that in the most recent version of mpl,
> one can no longer do bbox.height(), but must just do bbox.height ?
> (when I do it the first way it says float is not callable).

I'm pretty sure this is true.

>>        dx = x/width
>>        dy = y/height
>>
>>        # The following two lines are specific to our implementation
>> and our internal data classes
>>        self._legendLocation = (dx, dy)
>>        self.plot.getLegend().setLocation(self._legendLocation)
>
> So can I exclude them and still get the legend to move?

Yes.

>>        # This is the line that "moves" the legend
>>        self._legend._loc=(dx,dy)
>>
>>        if autoDraw:
>>            self.draw()
>>
>> Now we're using an ancient version of MPL (0.90.1) and many things
>> have changed in the meantime. YMMV.
>
> Thanks very much,
> Che

No worries.
A>

------------------------------------------------------------------------------
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to