Skip to content

Commit f9b06c8

Browse files
authored
Merge pull request #7323 from lzkelley/master
[MRG+1] Fix #6448: set xmin/ymin even without non-zero bins in 'step' hist
2 parents 1a9b4ee + 16d32a5 commit f9b06c8

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
@@ -6397,7 +6397,7 @@ def _normalize_input(inp, ename='input'):
63976397
xvals.append(x.copy())
63986398
yvals.append(y.copy())
63996399

6400-
#stepfill is closed, step is not
6400+
# stepfill is closed, step is not
64016401
split = -1 if fill else 2 * len(bins)
64026402
# add patches in reverse order so that when stacking,
64036403
# items lower in the stack are plottted on top of
@@ -6419,9 +6419,13 @@ def _normalize_input(inp, ename='input'):
64196419
xmin0 = max(_saved_bounds[0]*0.9, minimum)
64206420
xmax = self.dataLim.intervalx[1]
64216421
for m in n:
6422-
if np.sum(m) > 0: # make sure there are counts
6423-
xmin = np.amin(m[m != 0])
6422+
# make sure there are counts
6423+
if np.sum(m) > 0:
64246424
# filter out the 0 height bins
6425+
xmin = np.amin(m[m != 0])
6426+
# If no counts, set min to zero
6427+
else:
6428+
xmin = 0.0
64256429
xmin = max(xmin*0.9, minimum) if not input_empty else minimum
64266430
xmin = min(xmin0, xmin)
64276431
self.dataLim.intervalx = (xmin, xmax)
@@ -6430,9 +6434,13 @@ def _normalize_input(inp, ename='input'):
64306434
ymax = self.dataLim.intervaly[1]
64316435

64326436
for m in n:
6433-
if np.sum(m) > 0: # make sure there are counts
6434-
ymin = np.amin(m[m != 0])
6437+
# make sure there are counts
6438+
if np.sum(m) > 0:
64356439
# filter out the 0 height bins
6440+
ymin = np.amin(m[m != 0])
6441+
# If no counts, set min to zero
6442+
else:
6443+
ymin = 0.0
64366444
ymin = max(ymin*0.9, minimum) if not input_empty else minimum
64376445
ymin = min(ymin0, ymin)
64386446
self.dataLim.intervaly = (ymin, ymax)

0 commit comments

Comments
 (0)