Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8228dbd

Browse filesBrowse 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
Copy full SHA for 8228dbd

File tree

Expand file treeCollapse file tree

2 files changed

+14
-2
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+14
-2
lines changed

‎lib/matplotlib/axes/_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_axes.py
+10-2Lines 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

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_axes.py
+4Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.