Hi all,

I'm getting the following exception when I use the Span Selector.  It
happens when I try and select the entire region.

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 246, in motion_notify_event
    FigureCanvasBase.motion_notify_event(self, x, y, guiEvent=event)
  File "C:\Python26\Lib\site-packages\matplotlib\backend_bases.py", line
1245, in motion_notify_event
    self.callbacks.process(s, event)
  File "C:\Python26\Lib\site-packages\matplotlib\cbook.py", line 165, in
process
    func(*args, **kwargs)
  File "C:\Python26\Lib\site-packages\matplotlib\widgets.py", line 952, in
onmove
    self.rect.set_width(maxv-minv)
TypeError: unsupported operand type(s) for -: 'float' and 'NoneType'


My sample code is shown here (its also attached):

import matplotlib.pyplot as plt
from matplotlib.widgets import SpanSelector
import numpy as np
import datetime

class TimeSelector(SpanSelector):
    """
    SpanSelector that is only activated by the left mouse button
    """
    def ignore(self,event):
        if event.button == 2 or event.button == 3: return True

def onselect(xmin,xmax):
    print xmin,xmax

fig = plt.figure()
ax = fig.add_subplot(111)
span = TimeSelector(ax, onselect, 'horizontal', useblit=True,
rectprops=dict(alpha=0.5, facecolor='yellow') )

y = np.random.rand(100,1)
start = datetime.datetime(2010,7,15,0,0)
x = []
for i in range(len(y)):
    x.append(start + datetime.timedelta(hours=i))

ax.plot_date(x,y,'b-')
plt.show()

Any help on this issue would be greatly appreciated.

Thanks,
Aman

Attachment: spanselector_issue.py
Description: Binary data

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to