Title: [Bug]: Some styles trigger pcolormesh grid deprecation · Issue #21723 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: Some styles trigger pcolormesh grid deprecation · Issue #21723 · matplotlib/matplotlib
X Title: [Bug]: Some styles trigger pcolormesh grid deprecation · Issue #21723 · matplotlib/matplotlib
Description: Bug summary Calling plot_surface followed by fig.colorbar results in the following deprecation warning: Auto-removal of grids by pcolor() and pcolormesh() is deprecated since 3.5 and will be removed two minor releases later; please call ...
Open Graph Description: Bug summary Calling plot_surface followed by fig.colorbar results in the following deprecation warning: Auto-removal of grids by pcolor() and pcolormesh() is deprecated since 3.5 and will be remove...
X Description: Bug summary Calling plot_surface followed by fig.colorbar results in the following deprecation warning: Auto-removal of grids by pcolor() and pcolormesh() is deprecated since 3.5 and will be remove...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/21723
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: Some styles trigger pcolormesh grid deprecation","articleBody":"### Bug summary\r\n\r\nCalling `plot_surface` followed by `fig.colorbar` results in the following deprecation warning:\r\n```\r\nAuto-removal of grids by pcolor() and pcolormesh() is deprecated since 3.5\r\nand will be removed two minor releases later; please call grid(False) first.\r\n```\r\nHowever, setting `ax.grid(False)` first does not help, the Warning is still shown.\r\n\r\n### Code for reproduction\r\n\r\nEdit: As noted further down in the discussion: The warning does not appear for the default style. But if you load, e.g., `plt.style.use('bmh')`, you will see the warning.\r\n\r\n```python\r\n# https://matplotlib.org/stable/gallery/mplot3d/surface3d.html\r\n\r\nimport matplotlib.pyplot as plt\r\nfrom matplotlib import cm\r\nfrom matplotlib.ticker import LinearLocator\r\nimport numpy as np\r\n\r\nplt.style.use('bmh') # Edit: One of the styles with which you will see the warning\r\n\r\nfig, ax = plt.subplots(subplot_kw={\"projection\": \"3d\"})\r\n\r\n# Make data.\r\nX = np.arange(-5, 5, 0.25)\r\nY = np.arange(-5, 5, 0.25)\r\nX, Y = np.meshgrid(X, Y)\r\nR = np.sqrt(X**2 + Y**2)\r\nZ = np.sin(R)\r\n\r\n# Plot the surface.\r\nsurf = ax.plot_surface(X, Y, Z, cmap=cm.coolwarm,\r\n linewidth=0, antialiased=False)\r\n\r\n# Customize the z axis.\r\nax.set_zlim(-1.01, 1.01)\r\nax.zaxis.set_major_locator(LinearLocator(10))\r\n# A StrMethodFormatter is used automatically\r\nax.zaxis.set_major_formatter('{x:.02f}')\r\n\r\n# Add a color bar which maps values to colors.\r\nfig.colorbar(surf, shrink=0.5, aspect=5)\r\n\r\nplt.show()\r\n```\r\n\r\n\r\n### Actual outcome\r\n```\r\n MatplotlibDeprecationWarning: Auto-removal of grids by pcolor() and pcolormesh() is deprecated\r\n since 3.5 and will be removed two minor releases later; please call grid(False) first.\r\n fig.colorbar(surf, shrink=0.5, aspect=5)\r\n```\r\n\r\n### Expected outcome\r\n\r\nNo Warning or a warning with a fix that works.\r\n\r\n### Additional information\r\n\r\nWorks fine for `matplotlib\u003c3.5`.\r\n\r\n### Operating system\r\n\r\nLinux\r\n\r\n### Matplotlib Version\r\n\r\n3.5.0\r\n\r\n### Matplotlib Backend\r\n\r\nmodule://ipykernel.pylab.backend_inline\r\n\r\n### Python version\r\n\r\n3.88\r\n\r\n### Jupyter version\r\n\r\n6.4.0\r\n\r\n### Installation\r\n\r\nconda","author":{"url":"https://github.com/prisae","@type":"Person","name":"prisae"},"datePublished":"2021-11-23T06:00:37.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":17},"url":"https://github.com/21723/matplotlib/issues/21723"}
| 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:5815f806-f7cf-98c3-cfe8-2ccdef6ccb42 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D6FE:14F0B0:D77B75:1223A0C:6A5327FD |
| html-safe-nonce | 05044484e15dbeae2c12365062a9c55b6e730a4761f744ae494b5fec469c42c5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENkZFOjE0RjBCMDpENzdCNzU6MTIyM0EwQzo2QTUzMjdGRCIsInZpc2l0b3JfaWQiOiIyMTA3OTI2ODE2MzA0MDgwODkzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 51cac12d4aa90af5663d0976f5121849e54ee1b89c5e2ca6cbd78823fabeb036 |
| hovercard-subject-tag | issue:1060865940 |
| 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/21723/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a13cc04e2cc75be22d7ae718facba6beb1446e8cc5ec610d7b78cb8bdb58b45e/matplotlib/matplotlib/issues/21723 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a13cc04e2cc75be22d7ae718facba6beb1446e8cc5ec610d7b78cb8bdb58b45e/matplotlib/matplotlib/issues/21723 |
| og:image:alt | Bug summary Calling plot_surface followed by fig.colorbar results in the following deprecation warning: Auto-removal of grids by pcolor() and pcolormesh() is deprecated since 3.5 and will be remove... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | prisae |
| 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 | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width