8000 Fix traceback for vlines/hlines, when an empty list or array passed in for x/y. by dhyams · Pull Request #1000 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
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
dhyams committed Jul 10, 2012
commit 8f50a76d6c24ed402ce21f42b31beea6c97f88f7
17 changes: 9 additions & 8 deletions lib/matplotlib/axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
0