exception in hit testing with log scale axes

I was trying to implement something where the user could change the properties of an artist by right clicking on it…so I needed to find out what artists are under the cursor at the time of the click. It is possible that the method that I’m using isn’t the recommended one; if not, I would appreciate any suggestions.

I’m using fig.hitlist() to get the list of artists. This function works just fine with a regular xy plot, but if one (or both) of the axes are in log scale, I get a NotImplementedError exception and associated stack trace (run the attached demo code to see). The exception is being caused by line 249 in artists.py.

Now, if I modify artists.py slightly to swallow the exception, replacing

for a in self.get_children():

L.extend(a.hitlist(event))

with

try:

for a in self.get_children():

L.extend(a.hitlist(event))

except:

pass

Then everything seems to work. However, being unfamiliar with the code, I’m not sure what else that might break, or how bad of an idea swallowing the exception is here.

I have attached a small demo code. The error occurs in matplotlib 1.0.0 and matplotlib 1.0.1, on both Linux and Windows.

hitlist_problem.py (455 Bytes)

···


Daniel Hyams
dhyams@…287…