Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e7c51dc

Browse files
committed
Merge pull request #5600 from mdboom/empty-ranges
Fix #5572: Allow passing empty range to broken_barh
2 parents b6a79ac + 115fca7 commit e7c51dc

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

lib/matplotlib/axes/_axes.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2341,8 +2341,16 @@ def broken_barh(self, xranges, yrange, **kwargs):
23412341
.. plot:: mpl_examples/pylab_examples/broken_barh.py
23422342
"""
23432343
# process the unit information
2344-
self._process_unit_info(xdata=xranges[0],
2345-
ydata=yrange[0],
2344+
if len(xranges):
2345+
xdata = six.next(iter(xranges))
2346+
else:
2347+
xdata = None
2348+
if len(yrange):
2349+
ydata = six.next(iter(yrange))
2350+
else:
2351+
ydata = None
2352+
self._process_unit_info(xdata=xdata,
2353+
ydata=ydata,
23462354
kwargs=kwargs)
23472355
xranges = self.convert_xunits(xranges)
23482356
yrange = self.convert_yunits(yrange)

lib/matplotlib/tests/test_axes.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4241,6 +4241,12 @@ def _helper_y(ax):
42414241
assert assert_array_equal(ax_lst[0][1].get_xlim(), orig_xlim)
42424242

42434243

4244+
@cleanup
4245+
def test_broken_barh_empty():
4246+
fig, ax = plt.subplots()
4247+
ax.broken_barh([], (.1, .5))
4248+
4249+
42444250
if __name__ == '__main__':
42454251
import nose
42464252
import sys

0 commit comments

Comments
 (0)