bug: axes.hitlist() ?

I’ve run across a strange problem and perhaps I’m misusing something. I was trying to set up picking so that I can interact with plotted objects, and I get alot of error spew that looks like this:

while checking <class ‘matplotlib.lines.Line2D’>

Traceback (most recent call last):
File “C:\Python26\lib\site-packages\matplotlib\artist.py”, line 241, in hitlist
hascursor,info = self.contains(event)
File “C:\Python26\lib\site-packages\matplotlib\lines.py”, line 286, in contains

path, affine = self._transformed_path.get_transformed_path_and_affine()

AttributeError: ‘NoneType’ object has no attribute ‘get_transformed_path_and_affine’

This can be reproduced by the following code, even though there is no picking involved…just mouse motion. Is there possibly a workaround for this, or am I doing something wrong?

import sys
from pylab import *

ax = subplot(111)
ax.plot([0,1,2,3])

def on_move(event):
if event.inaxes:

    lst = ax.hitlist(event)
    print lst

binding_id = connect(‘motion_notify_event’, on_move)

show()

···


Daniel Hyams
dhyams@…287…

Daniel,

I am not exactly sure of your exact issue, but I did notice something a little off about your current code. In on_move(), you reference ‘ax’, but that is never passed in or defined in the function itself. Therefore, it is refering to the ‘ax’ that is in your global namespace. This seems to be a side issue, however.

Ben Root

···

On Tue, Oct 5, 2010 at 11:39 PM, Daniel Hyams <dhyams@…287…> wrote:

I’ve run across a strange problem and perhaps I’m misusing something. I was trying to set up picking so that I can interact with plotted objects, and I get alot of error spew that looks like this:

while checking <class ‘matplotlib.lines.Line2D’>

Traceback (most recent call last):
File “C:\Python26\lib\site-packages\matplotlib\artist.py”, line 241, in hitlist
hascursor,info = self.contains(event)
File “C:\Python26\lib\site-packages\matplotlib\lines.py”, line 286, in contains

path, affine = self._transformed_path.get_transformed_path_and_affine()

AttributeError: ‘NoneType’ object has no attribute ‘get_transformed_path_and_affine’

This can be reproduced by the following code, even though there is no picking involved…just mouse motion. Is there possibly a workaround for this, or am I doing something wrong?

import sys
from pylab import *

ax = subplot(111)
ax.plot([0,1,2,3])

def on_move(event):
if event.inaxes:

    lst = ax.hitlist(event)
    print lst

binding_id = connect(‘motion_notify_event’, on_move)

show()


Daniel Hyams

dhyams@…287…

It looks like Line2D.contains() was relying on some attributes that
were set by draw(). I'm not sure why those lines are not drawn (it
looks like some axis line?), but contains() shouldn't cause a
traceback regardless. I've fixed this in SVN. If you're not running
SVN, the patch is small, but it should be noted that the error message
you're seeing is purely cosmetic and shouldn't be causing any
problems.

Ryan

···

On Tue, Oct 5, 2010 at 11:39 PM, Daniel Hyams <dhyams@...287...> wrote:

I've run across a strange problem and perhaps I'm misusing something. I was
trying to set up picking so that I can interact with plotted objects, and I
get alot of error spew that looks like this:

while checking <class 'matplotlib.lines.Line2D'>
Traceback (most recent call last):
File "C:\Python26\lib\site-packages\matplotlib\artist.py", line 241, in
hitlist
hascursor,info = self.contains(event)
File "C:\Python26\lib\site-packages\matplotlib\lines.py", line 286, in
contains
path, affine = self._transformed_path.get_transformed_path_and_affine()
AttributeError: 'NoneType' object has no attribute
'get_transformed_path_and_affine'

This can be reproduced by the following code, even though there is no
picking involved...just mouse motion. Is there possibly a workaround for
this, or am I doing something wrong?

import sys
from pylab import *

ax = subplot(111)
ax.plot([0,1,2,3])

def on_move(event):
if event.inaxes:
lst = ax.hitlist(event)
print lst

binding_id = connect('motion_notify_event', on_move)

show()

--
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma