-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[Bug]: barplot does not show anything when x or bottom start and end with NaN #23687
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
I can reproduce this, but do not understand it yet. |
In 7c4b000 / #12903 we added some logic to make sure that width would work with interesting units, notable time deltas and and datetime data. To do this we effective add the width to the first element of the x data, run it through the conversion machinery, and then subtract off the already converted value of the first data point to convert the "width" in (possibly unitful) user data into our internal version of it. However, if the first point in |
I guess we should be using the new safe_first_element excluding NaNs? |
The new one only drops |
Due to the way we handle units on the bar width having an invalid value in the first position of the x bar (of y of barh) would effectively poison all of the widths making all of the bars invisible. This also renames the cbook function _safe_first_non_none function -> _safe_first_finite and adjusts the behavior to also drop nans closes matplotlib#23687
Due to the way we handle units on the bar width having an invalid value in the first position of the x bar (of y of barh) would effectively poison all of the widths making all of the bars invisible. This also renames the cbook function _safe_first_non_none function -> _safe_first_finite and adjusts the behavior to also drop nans closes matplotlib#23687
Bug summary
I am not sure if this is a bug or an optimization, but in most cases it is fine to plot bars of arrays containing NaN (only the NaN values are not displayed, the rest is ok).
Here I found that when the
x
array or thebottom
array have NaNs at the extremities, no bar is displayed.(
barh
has the same behavior).Code for reproduction
Actual outcome
zero bar displayed
Expected outcome
Non-NaN elements should be shown
Additional information
No response
Operating system
Ubuntu 20.04.3
Matplotlib Version
3.5.3
Matplotlib Backend
TkAgg, pdf
Python version
3.8.10
Jupyter version
ipython
Installation
pip
The text was updated successfully, but these errors were encountered: