You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
weighted_wiggle stackplot fails when all lines are zero at same x #6313
When using stackplot(..., baseline='weighted_wiggle') if all y arrays contain zero at some (interval of) x the plot stops rendering after that zero point.
importnumpyasnpimportmatplotlib.pyplotaspltx=np.arange(10)
y=np.random.random(10)
y2=np.random.random(10)
y3=np.random.random(10)
y[5] =0y3[5] =0fig, ax=plt.subplots(3,2, figsize=(12,8))
ax[0,0].stackplot(x, y, baseline='sym')
ax[0,1].stackplot(x, y, baseline='weighted_wiggle')
ax[1,0].stackplot(x, y, y2, baseline='sym')
ax[1,1].stackplot(x, y, y2, baseline='weighted_wiggle')
ax[2,0].stackplot(x, y, y3, baseline='sym')
ax[2,1].stackplot(x, y, y3, baseline='weighted_wiggle')
ax[0,0].set_title('sym: no problem')
ax[0,1].set_title('failed: stops after zero `y` (x>4)')
ax[1,1].set_title('success: non-zero `y2` saves the day')
ax[2,1].set_title('failed: stops after zero `y` and `y3` (x>4)')
plt.tight_layout()
plt.show()
I have this issue with Matplotlib 1.5.1, installed via pip, with Python 2.7.10 on Ubuntu Linux 15.10.
The problem is that there is the weighting which divides by the total weight to sort out how much to move the base line up or down. This results in a np.inf being throw in which (correctly) does not plot.
@egpbos Do you understand the underlying algorithm well enough to sort out what to do in this case?
On the left the old result, on the right the result with matplotlib 2.2.2.
I'm not sure whether this is completely expected behavior, especially the right-hand part which seems too high. But I would say the zero-issue is at least solved :)
Activity
tacaswell commentedon Apr 28, 2016
The problem is that there is the weighting which divides by the total weight to sort out how much to move the base line up or down. This results in a
np.infbeing throw in which (correctly) does not plot.@egpbos Do you understand the underlying algorithm well enough to sort out what to do in this case?
reference from source http://leebyron.com/streamgraph/
tacaswell commentedon Apr 28, 2016
attn @leebyron
egpbos commentedon Jul 10, 2018
On the left the old result, on the right the result with matplotlib 2.2.2.

I'm not sure whether this is completely expected behavior, especially the right-hand part which seems too high. But I would say the zero-issue is at least solved :)
dstansby commentedon Jul 21, 2019
Going to close this as fixed, feel free to comment or re-open if I've missed something.