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

Skip to content

Commit 8228dbd

Browse files
efiringtacaswell
authored andcommitted
Merge pull request #5600 from mdboom/empty-ranges
Fix #5572: Allow passing empty range to broken_barh
1 parent 345a8f9 commit 8228dbd

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

lib/matplotlib/axes/_axes.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2330,8 +2330,16 @@ def broken_barh(self, xranges, yrange, **kwargs):
23302330
.. plot:: mpl_examples/pylab_examples/broken_barh.py
23312331
"""
23322332
# process the unit information
2333-
self._process_unit_info(xdata=xranges[0],
2334-
ydata=yrange[0],
2333+
if len(xranges):
2334+
xdata = six.next(iter(xranges))
2335+
else:
2336+
xdata = None
2337+
if len(yrange):
2338+
ydata = six.next(iter(yrange))
2339+
else:
2340+
ydata = None
2341+
self._process_unit_info(xdata=xdata,
2342+
ydata=ydata,
23352343
kwargs=kwargs)
23362344
xranges = self.convert_xunits(xranges)
23372345
yrange = self.convert_yunits(yrange)

lib/matplotlib/tests/test_axes.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4177,6 +4177,10 @@ def _helper_y(ax):
41774177
assert assert_array_equal(ax_lst[0][1].get_xlim(), orig_xlim)
41784178

41794179

4180+
@cleanup
4181+
def test_broken_barh_empty():
4182+
fig, ax = plt.subplots()
4183+
ax.broken_barh([], (.1, .5))
41804184

41814185

41824186
if __name__ == '__main__':

0 commit comments

Comments
 (0)