Hi all,
I found a small bug in the Draggable Legend feature when you single-click on a
legend, but don't drag it. It raises a TypeError.
Here's code to reproduce. Try dragging the legend, then single-click the
legend.
#!/usr/bin/env python
import matplotlib as mpl
import pylab
fig = pylab.figure()
ax = fig.add_subplot(111)
ax.plot(range(10), range(10), c='r', marker='^', picker=5, label='Ramp')
legn = ax.legend()
legn.draggable()
pylab.show()
Here's the stacktrace when I single-click:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python26\lib\lib-tk\Tkinter.py", line 1410, in __call__
return self.func(*args)
File "C:\Python26\lib\site-packages\matplotlib\backends\backend_tkagg.py",
line 312, in button_release_event
FigureCanvasBase.button_release_event(self, x, y, num, guiEvent=event)
File "C:\Python26\lib\site-packages\matplotlib\backend_bases.py", line 1561,
in button_release_event
self.callbacks.process(s, event)
File "C:\Python26\lib\site-packages\matplotlib\cbook.py", line 262, in process
proxy(*args, **kwargs)
File "C:\Python26\lib\site-packages\matplotlib\cbook.py", line 188, in
__call__
return mtd(*args, **kwargs)
File "C:\Python26\lib\site-packages\matplotlib\offsetbox.py", line 1466, in
on_release
self.finalize_offset()
File "C:\Python26\lib\site-packages\matplotlib\legend.py", line 51, in
finalize_offset
loc_in_canvas = self.get_loc_in_canvas()
File "C:\Python26\lib\site-packages\matplotlib\offsetbox.py", line 1512, in
get_loc_in_canvas
ox, oy = offsetbox._offset
TypeError: 'instancemethod' object is not iterable
Jim