Skip to content

Commit

Permalink
Fix matplotlib#5572: Allow passing empty range to broken_barh
Browse files Browse the repository at this point in the history
  • Loading branch information
mdboom committed Dec 1, 2015
1 parent f420992 commit 5213b95
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/matplotlib/axes/_axes.py
Expand Up @@ -2333,8 +2333,16 @@ def broken_barh(self, xranges, yrange, **kwargs):
.. plot:: mpl_examples/pylab_examples/broken_barh.py
"""
# process the unit information
self._process_unit_info(xdata=xranges[0],
ydata=yrange[0],
if len(xranges):
xdata = xranges[0]
else:
xdata = None
if len(yrange):
ydata = yrange[0]
else:
ydata = None
self._process_unit_info(xdata=xdata,
ydata=ydata,
kwargs=kwargs)
xranges = self.convert_xunits(xranges)
yrange = self.convert_yunits(yrange)
Expand Down
5 changes: 5 additions & 0 deletions lib/matplotlib/tests/test_axes.py
Expand Up @@ -4130,6 +4130,11 @@ def test_dash_offset():
plt.show()


@cleanup
def test_broken_barh_empty():
fig, ax = plt.subplots()
ax.broken_barh([], (.1, .5))


if __name__ == '__main__':
import nose
Expand Down

0 comments on commit 5213b95

Please sign in to comment.