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

Skip to content

Commit b229f99

Browse files
committed
Merge pull request #7323 from lzkelley/master
[MRG+1] Fix #6448: set xmin/ymin even without non-zero bins in 'step' hist
1 parent bceea0c commit b229f99

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6393,7 +6393,7 @@ def _normalize_input(inp, ename='input'):
63936393
xvals.append(x.copy())
63946394
yvals.append(y.copy())
63956395

6396-
#stepfill is closed, step is not
6396+
# stepfill is closed, step is not
63976397
split = -1 if fill else 2 * len(bins)
63986398
# add patches in reverse order so that when stacking,
63996399
# items lower in the stack are plottted on top of
@@ -6415,9 +6415,13 @@ def _normalize_input(inp, ename='input'):
64156415
xmin0 = max(_saved_bounds[0]*0.9, minimum)
64166416
xmax = self.dataLim.intervalx[1]
64176417
for m in n:
6418-
if np.sum(m) > 0: # make sure there are counts
6419-
xmin = np.amin(m[m != 0])
6418+
# make sure there are counts
6419+
if np.sum(m) > 0:
64206420
# filter out the 0 height bins
6421+
xmin = np.amin(m[m != 0])
6422+
# If no counts, set min to zero
6423+
else:
6424+
xmin = 0.0
64216425
xmin = max(xmin*0.9, minimum) if not input_empty else minimum
64226426
xmin = min(xmin0, xmin)
64236427
self.dataLim.intervalx = (xmin, xmax)
@@ -6426,9 +6430,13 @@ def _normalize_input(inp, ename='input'):
64266430
ymax = self.dataLim.intervaly[1]
64276431

64286432
for m in n:
6429-
if np.sum(m) > 0: # make sure there are counts
6430-
ymin = np.amin(m[m != 0])
6433+
# make sure there are counts
6434+
if np.sum(m) > 0:
64316435
# filter out the 0 height bins
6436+
ymin = np.amin(m[m != 0])
6437+
# If no counts, set min to zero
6438+
else:
6439+
ymin = 0.0
64326440
ymin = max(ymin*0.9, minimum) if not input_empty else minimum
64336441
ymin = min(ymin0, ymin)
64346442
self.dataLim.intervaly = (ymin, ymax)

0 commit comments

Comments
 (0)