-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
fill_between, step='post' and NaN #19444
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
Comments
If possible can you simplify this to Matplotlib with no dates, no pandas, and maybe the latest release? I think fill-between may have had some work recently. Thanks! |
For instance if I do: import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure(1)
ax = fig.add_subplot(111)
x = np.arange(30)
np.random.seed(1)
y = np.cumsum(np.random.randn(30))
y = y - np.mean(y)
ax.plot(x, y, drawstyle='steps-post')
yy = y
yy[y<0] = 0
ax.fill_between(x, yy, step='post')
plt.show() I get what I think you are trying to do, so I'm guessing this is actually to do with how you are using pandas (but I could certainly be wrong): |
Yes this works with the extra code you've provided: Thanks for the push to simplify the bug. It is an NaN bug, and I think this should work with NaNs, although replacing NaNs with 0 is not a big burden. import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure(1)
ax = fig.add_subplot(111)
x = np.arange(1,11)
y = np.array([1,2,3,-4,-5,-6,7,8,9,-10])
yn = np.where(y > 0, y, np.nan)
ax.plot(x, y, drawstyle='steps-post')
ax.fill_between(x, yn, step='post')
plt.show() The above code generates the first graphic: https://user-images.githubusercontent.com/145117/106748570-46cc4480-65da-11eb-8e38-83e2d4e02fc2.png |
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help! |
Off-by-one error if using
fill_between
,step='post'
Actual outcome
Expected outcome
Some of the
df[df > 0]
columns are not filled.Matplotlib version
import matplotlib; print(matplotlib.__version__)
): 3.3.1print(matplotlib.get_backend())
): Qt5AggThe text was updated successfully, but these errors were encountered: