Skip to content

Commit 102872a

Browse files
committed
Merge pull request #6358 from egpbos/stackplot_6313
FIX: Stackplot weighted_wiggle zero-area
1 parent 846b95f commit 102872a

File tree

5 files changed

+781
-790
lines changed

5 files changed

+781
-790
lines changed

lib/matplotlib/stackplot.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,12 @@ def stackplot(axes, x, *args, **kwargs):
9191
m, n = y.shape
9292
center = np.zeros(n)
9393
total = np.sum(y, 0)
94+
# multiply by 1/total (or zero) to avoid infinities in the division:
95+
inv_total = np.where(total > 0, 1./total, 0)
9496
increase = np.hstack((y[:, 0:1], np.diff(y)))
9597
below_size = total - stack
9698
below_size += 0.5 * y
97-
move_up = below_size / total
99+
move_up = below_size * inv_total
98100
move_up[:, 0] = 0.5
99101
center = (move_up - 0.5) * increase
100102
center = np.cumsum(center.sum(0))
Binary file not shown.

0 commit comments

Comments
 (0)