Skip to content
Browse files

Handle the edge case in matplotlib.axes.vlines, where an empty list o…

…r 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
  • Loading branch information...
1 parent 2bb91ce commit 8f50a76d6c24ed402ce21f42b31beea6c97f88f7 @dhyams committed
Showing with 9 additions and 8 deletions.
  1. +9 −8 lib/matplotlib/axes.py
View
17 lib/matplotlib/axes.py
@@ -3706,16 +3706,17 @@ def vlines(self, x, ymin, ymax, colors='k', linestyles='solid',
linestyles=linestyles, label=label)
self.add_collection(coll)
coll.update(kwargs)
+
+ if len(x) > 0:
+ minx = min( x )
+ maxx = max( x )
- minx = min( x )
- maxx = max( x )
+ miny = min( min(ymin), min(ymax) )
+ maxy = max( max(ymin), max(ymax) )
- miny = min( min(ymin), min(ymax) )
- maxy = max( max(ymin), max(ymax) )
-
- corners = (minx, miny), (maxx, maxy)
- self.update_datalim(corners)
- self.autoscale_view()
+ corners = (minx, miny), (maxx, maxy)
+ self.update_datalim(corners)
+ self.autoscale_view()
return coll

0 comments on commit 8f50a76

Please sign in to comment.
Something went wrong with that request. Please try again.