Skip to content

Commit 8f50a76

Browse files
committed
Handle the edge case in matplotlib.axes.vlines, where an empty list or array is passed in as x. Previously,
the vlines routine would raise an exception when min(x) was called, if x was an empty list.wq
1 parent 2bb91ce commit 8f50a76

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

lib/matplotlib/axes.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -3706,16 +3706,17 @@ def vlines(self, x, ymin, ymax, colors='k', linestyles='solid',
37063706
linestyles=linestyles, label=label)
37073707
self.add_collection(coll)
37083708
coll.update(kwargs)
3709+
3710+
if len(x) > 0:
3711+
minx = min( x )
3712+
maxx = max( x )
37093713

3710-
minx = min( x )
3711-
maxx = max( x )
3714+
miny = min( min(ymin), min(ymax) )
3715+
maxy = max( max(ymin), max(ymax) )
37123716

3713-
miny = min( min(ymin), min(ymax) )
3714-
maxy = max( max(ymin), max(ymax) )
3715-
3716-
corners = (minx, miny), (maxx, maxy)
3717-
self.update_datalim(corners)
3718-
self.autoscale_view()
3717+
corners = (minx, miny), (maxx, maxy)
3718+
self.update_datalim(corners)
3719+
self.autoscale_view()
37193720

37203721
return coll
37213722

0 commit comments

Comments
 (0)