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

Skip to content

Commit f40b0f8

Browse files
committed
Fix stepfilled histogram polygon bottom perimeter
The polygon generated by hist() when histtype='stepfilled' and bottom is not None contained an invalid starting point with a y-value of zero resulting in a diagonal line at the bottom of the first bin. This commit fixes the computation of the starting point and thus removes the drawing artifacts from the first bin.
1 parent 60a785d commit f40b0f8

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6796,13 +6796,18 @@ def hist(self, x, bins=None, range=None, density=False, weights=None,
67966796
xvals, yvals = [], []
67976797
for m in tops:
67986798
if stacked:
6799-
# starting point for drawing polygon
6800-
y[0] = y[1]
68016799
# top of the previous polygon becomes the bottom
68026800
y[2*len(bins)-1:] = y[1:2*len(bins)-1][::-1]
68036801
# set the top of this polygon
68046802
y[1:2*len(bins)-1:2], y[2:2*len(bins):2] = (m + bottom,
68056803
m + bottom)
6804+
6805+
# The starting point of the polygon has not yet been
6806+
# updated. So far only the endpoint was adjusted. This
6807+
# assignment closes the polygon. The redundant endpoint is
6808+
# later discarded (for step and stepfilled).
6809+
y[0] = y[-1]
6810+
68066811
if orientation == 'horizontal':
68076812
xvals.append(y.copy())
68086813
yvals.append(x.copy())

0 commit comments

Comments
 (0)