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

Skip to content

weighted_wiggle stackplot fails when all lines are zero at same x #6313

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
egpbos opened this issue Apr 18, 2016 · 4 comments
Closed

weighted_wiggle stackplot fails when all lines are zero at same x #6313

egpbos opened this issue Apr 18, 2016 · 4 comments

Comments

@egpbos
Copy link
Contributor

egpbos commented Apr 18, 2016

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.

import numpy as np
import matplotlib.pyplot as plt

x = np.arange(10)
y = np.random.random(10)
y2 = np.random.random(10)
y3 = np.random.random(10)

y[5] = 0
y3[5] = 0

fig, 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.

@tacaswell
Copy link
Member

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?

reference from source http://leebyron.com/streamgraph/

@tacaswell
Copy link
Member

attn @leebyron

@tacaswell tacaswell added this to the 2.0.1 (next bug fix release) milestone Apr 28, 2016
@QuLogic QuLogic modified the milestones: 2.0.1 (next bug fix release), 2.0.2 (next bug fix release) May 3, 2017
@tacaswell tacaswell modified the milestones: 2.1.1 (next bug fix release), 2.2 (next feature release) Oct 9, 2017
@egpbos
Copy link
Contributor Author

egpbos commented Jul 10, 2018

On the left the old result, on the right the result with matplotlib 2.2.2.
schermafbeelding 2018-07-10 om 11 29 32

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
Copy link
Member

Going to close this as fixed, feel free to comment or re-open if I've missed something.

@story645 story645 removed this from the future releases milestone Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants