Title: [Bug]: barplot does not show anything when x or bottom start and end with NaN · Issue #23687 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: barplot does not show anything when x or bottom start and end with NaN · Issue #23687 · matplotlib/matplotlib
X Title: [Bug]: barplot does not show anything when x or bottom start and end with NaN · Issue #23687 · matplotlib/matplotlib
Description: 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 the bottom a...
Open Graph Description: 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 fou...
X Description: 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 fou...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/23687
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: barplot does not show anything when x or bottom start and end with NaN","articleBody":"### Bug summary\n\nI 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).\r\n\r\nHere I found that when the `x` array or the `bottom` array have NaNs at the extremities, no bar is displayed.\r\n\r\n(`barh` has the same behavior).\n\n### Code for reproduction\n\n```python\nimport numpy as np, matplotlib as mpl, matplotlib.pyplot as plt\r\n\r\nbarx = np.arange(3, dtype=float)\r\nbarheights = np.array([0.5, 1.5, 2.0])\r\nbarstarts=np.array([0.77]*3)\r\n\r\nbarx[[0,2]] = np.NaN\r\n# alternatively:\r\n#barstarts[[0,2]] = np.NaN\r\n\r\nfig, ax = plt.subplots()\r\n\r\nax.bar(barx, barheights, bottom=barstarts)\r\n# Not ok, nothing shown!\r\n\r\n# Same behavior with ax.barh:\r\nax.barh(barx, barheights, left=barstarts)\r\n\r\n# However, the behavior is correct when NaN only affect the 'heights' argument:\r\n\r\nfig, ax = plt.subplots()\r\nax.bar(np.arange(3), np.array([np.NaN, 1, np.NaN]), bottom=np.array([0.2, 0.3, 0.4]))\r\n# OK, one bar is displayed.\n```\n\n\n### Actual outcome\n\nzero bar displayed\n\n### Expected outcome\n\nNon-NaN elements should be shown\n\n### Additional information\n\n_No response_\n\n### Operating system\n\nUbuntu 20.04.3\n\n### Matplotlib Version\n\n3.5.3\n\n### Matplotlib Backend\n\nTkAgg, pdf\n\n### Python version\n\n3.8.10\n\n### Jupyter version\n\nipython\n\n### Installation\n\npip","author":{"url":"https://github.com/Gullumluvl","@type":"Person","name":"Gullumluvl"},"datePublished":"2022-08-20T22:07:12.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/23687/matplotlib/issues/23687"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:af726e94-36d4-82d7-f831-e800d2340bbd |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 871A:1D1D40:34A92:452DA:6A516D85 |
| html-safe-nonce | 8b0d87da9be2efaaa8580bf025a276e5b85c0772ae3fc7ef221a31de034f57be |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NzFBOjFEMUQ0MDozNEE5Mjo0NTJEQTo2QTUxNkQ4NSIsInZpc2l0b3JfaWQiOiI4Njk2OTQzMjQwMTA3MDkzMzgxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 5bb968c69d07aac3e4670b5212de27cb235c329dc43211697f780166b05e8cd8 |
| hovercard-subject-tag | issue:1345309878 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/matplotlib/matplotlib/23687/issue_layout |
| twitter:image | https://opengraph.githubassets.com/15e08c80a7acde63c76c60e0c3ab664f4f07379d1b726bbb0f5be5d2e7878bae/matplotlib/matplotlib/issues/23687 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/15e08c80a7acde63c76c60e0c3ab664f4f07379d1b726bbb0f5be5d2e7878bae/matplotlib/matplotlib/issues/23687 |
| og:image:alt | 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 fou... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Gullumluvl |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 60eaaf6d4dbaa817031b556aebd8a0a7eeb81b97 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width