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 f6b7f28

Browse filesBrowse files
committed
Merge pull request #1000 from dhyams/fix_vlines
Fix traceback for vlines/hlines, when an empty list or array passed in for x/y.
2 parents 8c57e4f + d65269d commit f6b7f28
Copy full SHA for f6b7f28

File tree

Expand file treeCollapse file tree

1 file changed

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

1 file changed

+17
-15
lines changed

‎lib/matplotlib/axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes.py
+17-15Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3674,15 +3674,16 @@ def hlines(self, y, xmin, xmax, colors='k', linestyles='solid',
36743674
self.add_collection(coll)
36753675
coll.update(kwargs)
36763676

3677-
minx = min(xmin.min(), xmax.min())
3678-
maxx = max(xmin.max(), xmax.max())
3679-
miny = y.min()
3680-
maxy = y.max()
3677+
if len(y) > 0:
3678+
minx = min(xmin.min(), xmax.min())
3679+
maxx = max(xmin.max(), xmax.max())
3680+
miny = y.min()
3681+
maxy = y.max()
36813682

3682-
corners = (minx, miny), (maxx, maxy)
3683+
corners = (minx, miny), (maxx, maxy)
36833684

3684-
self.update_datalim(corners)
3685-
self.autoscale_view()
3685+
self.update_datalim(corners)
3686+
self.autoscale_view()
36863687

36873688

36883689
return coll
@@ -3752,16 +3753,17 @@ def vlines(self, x, ymin, ymax, colors='k', linestyles='solid',
37523753
linestyles=linestyles, label=label)
37533754
self.add_collection(coll)
37543755
coll.update(kwargs)
3756+
3757+
if len(x) > 0:
3758+
minx = min( x )
3759+
maxx = max( x )
37553760

3756-
minx = min( x )
3757-
maxx = max( x )
3758-
3759-
miny = min( min(ymin), min(ymax) )
3760-
maxy = max( max(ymin), max(ymax) )
3761+
miny = min( min(ymin), min(ymax) )
3762+
maxy = max( max(ymin), max(ymax) )
37613763

3762-
corners = (minx, miny), (maxx, maxy)
3763-
self.update_datalim(corners)
3764-
self.autoscale_view()
3764+
corners = (minx, miny), (maxx, maxy)
3765+
self.update_datalim(corners)
3766+
self.autoscale_view()
37653767

37663768
return coll
37673769

0 commit comments

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