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 f255c33

Browse filesBrowse files
committed
Fix #5572: Allow passing empty range to broken_barh
1 parent f413b78 commit f255c33
Copy full SHA for f255c33

File tree

Expand file treeCollapse file tree

2 files changed

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

2 files changed

+16
-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
@@ -2339,8 +2339,16 @@ def broken_barh(self, xranges, yrange, **kwargs):
23392339
.. plot:: mpl_examples/pylab_examples/broken_barh.py
23402340
"""
23412341
# process the unit information
2342-
self._process_unit_info(xdata=xranges[0],
2343-
ydata=yrange[0],
2342+
if len(xranges):
2343+
xdata = xranges[0]
2344+
else:
2345+
xdata = None
2346+
if len(yrange):
2347+
ydata = yrange[0]
2348+
else:
2349+
ydata = None
2350+
self._process_unit_info(xdata=xdata,
2351+
ydata=ydata,
23442352
kwargs=kwargs)
23452353
xranges = self.convert_xunits(xranges)
23462354
yrange = self.convert_yunits(yrange)

‎lib/matplotlib/tests/test_axes.py

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