8000 Fix #6448: set xmin/ymin even when there are no non-zero bins in 'ste… · matplotlib/matplotlib@16d32a5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 16d32a5

Browse files
author
lzkelley
committed
Fix #6448: set xmin/ymin even when there are no non-zero bins in 'step' histograms.
1 parent c93dff4 commit 16d32a5

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
@@ -6390,7 +6390,7 @@ def _normalize_input(inp, ename='input'):
63906390
xvals.append(x.copy())
63916391
yvals.append(y.copy())
63926392

6393-
#stepfill is closed, step is not
6393+
# stepfill is closed, step is not
63946394
split = -1 if fill else 2 * len(bins)
63956395
# add patches in reverse order so that when stacking,
63966396
# items lower in the stack are plottted on top of
@@ -6412,9 +6412,13 @@ def _normalize_input(inp, ename='input'):
64126412
xmin0 = max(_saved_bounds[0]*0.9, minimum)
64136413
xmax = self.dataLim.intervalx[1]
64146414
for m in n:
6415-
if np.sum(m) > 0: # make sure there are counts
6416-
xmin = np.amin(m[m != 0])
6415+
# make sure there are counts
6416+
if np.sum(m) > 0:
64176417
# filter out the 0 height bins
6418+
xmin = np.amin(m[m != 0])
6419+
# If no counts, set min to zero
6420+
else:
6421+
xmin = 0.0
64186422
xmin = max(xmin*0.9, minimum) if not input_empty else minimum
64196423
xmin = min(xmin0, xmin)
64206424
self.dataLim.intervalx = (xmin, xmax)
@@ -6423,9 +6427,13 @@ def _normalize_input(inp, ename='input'):
64236427
ymax = self.dataLim.intervaly[1]
64246428

64256429
for m in n:
6426-
if np.sum(m) > 0: # make sure there are counts
6427-
ymin = np.amin(m[m != 0])
6430+
# make sure there are counts
6431+
if np.sum(m) > 0:
64286432
# filter out the 0 height bins
6433+
ymin = np.amin(m[m != 0])
6434+
# If no counts, set min to zero
6435+
else:
6436+
ymin = 0.0
64296437
ymin = max(ymin*0.9, minimum) if not input_empty else minimum
64306438
ymin = min(ymin0, ymin)
64316439
self.dataLim.intervaly = (ymin, ymax)

0 commit comments

Comments
 (0)
0