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

Skip to content

Commit 2786e39

Browse files
committed
Fixed another location where empty datasets in hist caused exceptions
1 parent 5a2c9af commit 2786e39

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/matplotlib/axes.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8511,15 +8511,17 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
85118511
xmin0 = max(_saved_bounds[0]*0.9, minimum)
85128512
xmax = self.dataLim.intervalx[1]
85138513
for m in n:
8514-
xmin = np.amin(m[m != 0]) # filter out the 0 height bins
8514+
if np.sum(m) > 0: # make sure there are counts
8515+
xmin = np.amin(m[m != 0]) # filter out the 0 height bins
85158516
xmin = max(xmin*0.9, minimum)
85168517
xmin = min(xmin0, xmin)
85178518
self.dataLim.intervalx = (xmin, xmax)
85188519
elif orientation == 'vertical':
85198520
ymin0 = max(_saved_bounds[1]*0.9, minimum)
85208521
ymax = self.dataLim.intervaly[1]
85218522
for m in n:
8522-
ymin = np.amin(m[m != 0]) # filter out the 0 height bins
8523+
if np.sum(m) > 0: # make sure there are counts
8524+
ymin = np.amin(m[m != 0]) # filter out the 0 height bins
85238525
ymin = max(ymin*0.9, minimum)
85248526
ymin = min(ymin0, ymin)
85258527
self.dataLim.intervaly = (ymin, ymax)

0 commit comments

Comments
 (0)