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

Skip to content

Commit 554bd48

Browse files
committed
Handled edge case for hlines also; if y is an empty list or zero-length array, the routine
would raise an exception.
1 parent 8f50a76 commit 554bd48

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

lib/matplotlib/axes.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3626,15 +3626,16 @@ def hlines(self, y, xmin, xmax, colors='k', linestyles='solid',
36263626
self.add_collection(coll)
36273627
coll.update(kwargs)
36283628

3629-
minx = min(xmin.min(), xmax.min())
3630-
maxx = max(xmin.max(), xmax.max())
3631-
miny = y.min()
3632-
maxy = y.max()
3629+
if len(x) > 0:
3630+
minx = min(xmin.min(), xmax.min())
3631+
maxx = max(xmin.max(), xmax.max())
3632+
miny = y.min()
3633+
maxy = y.max()
36333634

3634-
corners = (minx, miny), (maxx, maxy)
3635+
corners = (minx, miny), (maxx, maxy)
36353636

3636-
self.update_datalim(corners)
3637-
self.autoscale_view()
3637+
self.update_datalim(corners)
3638+
self.autoscale_view()
36383639

36393640

36403641
return coll

0 commit comments

Comments
 (0)