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 3b3299f

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

File tree

Expand file treeCollapse file tree

2 files changed

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

2 files changed

+15
-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
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4191,6 +4191,11 @@ def test_axes_margins():
41914191
assert ax.get_ybound() == (-0.5, 9.5)
41924192

41934193

4194+
def test_broken_barh_empty():
4195+
fig, ax = plt.subplots()
4196+
ax.broken_barh([], (.1, .5))
4197+
4198+
41944199
if __name__ == '__main__':
41954200
import nose
41964201
import sys

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.