Title: [Bug]: Data 0 cannot be plotted by matplotlib.pyplot just because some data is less than 0. · Issue #21382 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: Data 0 cannot be plotted by matplotlib.pyplot just because some data is less than 0. · Issue #21382 · matplotlib/matplotlib
X Title: [Bug]: Data 0 cannot be plotted by matplotlib.pyplot just because some data is less than 0. · Issue #21382 · matplotlib/matplotlib
Description: Bug summary Data 0 cannot be plotted and the corresponding area in the the figure remains transparent, if some data is less than 0. I tried to trace the problem and find that the reason seems to be a bug in ContourSet._get_lowers_and_upp...
Open Graph Description: Bug summary Data 0 cannot be plotted and the corresponding area in the the figure remains transparent, if some data is less than 0. I tried to trace the problem and find that the reason seems to be...
X Description: Bug summary Data 0 cannot be plotted and the corresponding area in the the figure remains transparent, if some data is less than 0. I tried to trace the problem and find that the reason seems to be...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/21382
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: Data 0 cannot be plotted by matplotlib.pyplot just because some data is less than 0.","articleBody":"### Bug summary\n\nData 0 cannot be plotted and the corresponding area in the the figure remains transparent, if some data is less than 0.\r\n\r\nI tried to trace the problem and find that the reason seems to be a bug in ContourSet._get_lowers_and_uppers.(Line 1065 in contour.py(3.3.4))\r\n\r\n if self.zmin == lowers[0]:\r\n # Include minimum values in lowest interval\r\n lowers = lowers.copy() # so we don't change self._levels\r\n if self.logscale:\r\n lowers[0] = 0.99 * self.zmin\r\n else:\r\n lowers[0] -= 1\r\n\r\nwhile lowers[0] is the same as self.zmin, it will be reduced a little before using. \r\nHowever, while lowers[0] is greater than self.zmin ( = -1.7E-13 ), it will not be reduced and remains as it is.\r\nI think the condition should be revised to self.zmin \u003c= lowers[0] from self.zmin == lowers[0]. \n\n### Code for reproduction\n\n```python\nimport numpy as np\r\nimport matplotlib.pyplot as plt\r\n\r\ndef main():\r\n z0 = np.array([[0., 0., 2.], [0., 0., 1.], [2., 1., 0.]])\r\n z1 = np.array([[0., 0., 2.], [0., 0., 1.], [2., 1., -1.7E-13]])\r\n\r\n fig = plt.figure(figsize=(2, 4))\r\n\r\n ax0 = fig.add_subplot(121)\r\n ax0.contourf(z0, cmap='jet')\r\n ax0.set_aspect('equal')\r\n\r\n ax1 = fig.add_subplot(122)\r\n ax1.contourf(z1, cmap='jet')\r\n ax1.set_aspect('equal')\r\n\r\n plt.show()\r\n\r\nif __name__ == \"__main__\":\r\n main()\n```\n\n\n### Actual outcome\n\n\r\n\r\nthe left-bottom area in the right figure is not plotted and remains transparent,\r\n just because the data z[2,2] is changed from 0 to -1.7E-13.\r\n\n\n### Expected outcome\n\n\r\n\r\nThe figure in the right site is expected to be the same as the left one.\n\n### Operating system\n\nWindows 10\n\n### Matplotlib Version\n\n3.3.4\n\n### Matplotlib Backend\n\nmodule://ipykernel.pylab.backend_inline\n\n### Python version\n\n 3.8.8\n\n### Jupyter version\n\n6.0.1\n\n### Other libraries\n\n_No response_\n\n### Installation\n\nconda\n\n### Conda channel\n\n_No response_","author":{"url":"https://github.com/JK-SHI","@type":"Person","name":"JK-SHI"},"datePublished":"2021-10-19T16:03:17.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":9},"url":"https://github.com/21382/matplotlib/issues/21382"}
| 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:95d31822-797d-2fd0-b5c3-d98c9e663f2d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 808A:B5C81:15CFF:1D958:6A524B4C |
| html-safe-nonce | 00854dd0b6c391fd3d0bcc458a1919394d95c60b62dac645f8964044c0ccc6c0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MDhBOkI1QzgxOjE1Q0ZGOjFEOTU4OjZBNTI0QjRDIiwidmlzaXRvcl9pZCI6IjcxNTEzMjEyNTc3NDA0ODc1MDAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 8cbefc63d143cee9d2d803304893437f22e150ce114930090624ddb6ec787563 |
| hovercard-subject-tag | issue:1030491080 |
| 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/21382/issue_layout |
| twitter:image | https://opengraph.githubassets.com/645d30ba33d46af568105f63cfe0503bc40d5444adacc641ceb50e3c01eafc53/matplotlib/matplotlib/issues/21382 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/645d30ba33d46af568105f63cfe0503bc40d5444adacc641ceb50e3c01eafc53/matplotlib/matplotlib/issues/21382 |
| og:image:alt | Bug summary Data 0 cannot be plotted and the corresponding area in the the figure remains transparent, if some data is less than 0. I tried to trace the problem and find that the reason seems to be... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | JK-SHI |
| 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 | 7aed05249554b889eb33d002851a973eebcc7e91 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width