bar plot picker with 0 height data

I get an exception when I set up a bar chart with a picker that has a
bar with 0 height, and I click on the chart.

Code to generate exception:

from matplotlib.pyplot import figure, show

import numpy as np

def onpick1(event):

print 'foo'

fig = figure()

ax = fig.add_subplot(111)

xdata = [1, 2, 3]

ydata = [1, 0, 3] #change to [1, 2, 3] and code will run fine

ax.bar(xdata,

   ydata,

   picker = True)

fig.canvas.mpl_connect(‘pick_event’, onpick1)

show()

#now click on chart

···

Exception generated:

Exception in Tkinter callback

Traceback (most recent call last):

File “C:\Python24\lib\lib-tk\Tkinter.py”, line 1345,
in call

return self.func(*args)

File
“C:\Python24\Lib\site-packages\matplotlib\backends\backend_tkagg.py”,
line 236, in button_press_event

FigureCanvasBase.button_press_event(self, x, y, num,

guiEvent=event)

File
“C:\Python24\Lib\site-packages\matplotlib\backend_bases.py”, line
1074, in button_press_event

self.callbacks.process(s, mouseevent)

File
“C:\Python24\Lib\site-packages\matplotlib\cbook.py”, line 152, in
process

func(*args, **kwargs)

File
“C:\Python24\Lib\site-packages\matplotlib\backend_bases.py”, line
983, in pick

self.figure.pick(mouseevent)

File “C:\Python24\Lib\site-packages\matplotlib\artist.py”,
line 226, in pick

for a in self.get_children(): a.pick(mouseevent)

File
“C:\Python24\Lib\site-packages\matplotlib\axes.py”, line 2306, in
pick

martist.Artist.pick(self,args[0])

File “C:\Python24\Lib\site-packages\matplotlib\artist.py”,
line 226, in pick

for a in self.get_children(): a.pick(mouseevent)

File
“C:\Python24\Lib\site-packages\matplotlib\artist.py”, line 220, in
pick

inside,prop = self.contains(mouseevent)

File “C:\Python24\Lib\site-packages\matplotlib\patches.py”,
line 385, in contains

x, y =

self.get_transform().inverted().transform_point(

File
“C:\Python24\Lib\site-packages\matplotlib\transforms.py”, line 1840,
in inverted

return CompositeGenericTransform(self._b.inverted(),

self._a.inverted())

File
“C:\Python24\Lib\site-packages\matplotlib\transforms.py”, line 1338,
in inverted

self._inverted = Affine2D(inv(mtx))

File
“C:\Python24\Lib\site-packages\numpy\linalg\linalg.py”, line 332, in
inv

return wrap(solve(a, identity(a.shape[0],

dtype=a.dtype)))

File
“C:\Python24\Lib\site-packages\numpy\linalg\linalg.py”, line 235, in
solve

raise LinAlgError, 'Singular matrix'

LinAlgError: Singular matrix


Stats:

MPL 0.98.1

Python 2.4.4

Numpy 1.1.0

I get the error on both Windows and Linux

Thanks,

-Ben

Thanks for the report -- I just committed a fix for this to svn r5922

JDH

···

On Tue, Jul 29, 2008 at 12:27 PM, Ben Axelrod <baxelrod@...2066...> wrote:

I get an exception when I set up a bar chart with a picker that has a bar
with 0 height, and I click on the chart.

Thanks for the bug fix. Do you think this fix will make it into the 0.98.3 release?

···

-----Original Message-----
From: John Hunter [mailto:jdh2358@…287…]
Sent: Tuesday, July 29, 2008 1:49 PM
To: Ben Axelrod
Cc: matplotlib-users@lists.sourceforge.net
Subject: Re: [Matplotlib-users] bar plot picker with 0 height data

On Tue, Jul 29, 2008 at 12:27 PM, Ben Axelrod <baxelrod@...2066...> wrote:

I get an exception when I set up a bar chart with a picker that has a bar
with 0 height, and I click on the chart.

Thanks for the report -- I just committed a fix for this to svn r5922

JDH

it will.

···

On Tue, Jul 29, 2008 at 1:20 PM, Ben Axelrod <baxelrod@...2066...> wrote:

Thanks for the bug fix. Do you think this fix will make it into the 0.98.3 release?