Title: [Bug]: Matplotlib >= 3.5.0 drops scientific notation for colorbars using log ticks · Issue #24002 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: Matplotlib >= 3.5.0 drops scientific notation for colorbars using log ticks · Issue #24002 · matplotlib/matplotlib
X Title: [Bug]: Matplotlib >= 3.5.0 drops scientific notation for colorbars using log ticks · Issue #24002 · matplotlib/matplotlib
Description: Bug summary When using logarithmic scaling of the data with 2D plots, the ticks for the colorbar are not written in scientific notation. Prior to Matplotlib 3.5.0 (e.g. 3.4.3), scientific notation was used, as one would expect. The probl...
Open Graph Description: Bug summary When using logarithmic scaling of the data with 2D plots, the ticks for the colorbar are not written in scientific notation. Prior to Matplotlib 3.5.0 (e.g. 3.4.3), scientific notation ...
X Description: Bug summary When using logarithmic scaling of the data with 2D plots, the ticks for the colorbar are not written in scientific notation. Prior to Matplotlib 3.5.0 (e.g. 3.4.3), scientific notation ...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/24002
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: Matplotlib \u003e= 3.5.0 drops scientific notation for colorbars using log ticks","articleBody":"### Bug summary\r\n\r\nWhen using logarithmic scaling of the data with 2D plots, the ticks for the colorbar are not written in scientific notation. Prior to Matplotlib 3.5.0 (e.g. 3.4.3), scientific notation was used, as one would expect. The problem persists in 3.6.\r\n\r\n### Code for reproduction\r\n\r\n```python\r\n# Sample code for 2D plotting with log scaling,\r\n# with the log scaling implemented\r\n# using two different methods.\r\n\r\nimport numpy as np\r\nimport matplotlib\r\nimport matplotlib.pyplot as plt\r\n\r\nn = 100\r\nnp.random.seed(42)\r\nx = np.random.random(n)\r\ny = np.random.random(n)\r\nz = np.logspace(np.log10(1e-7), np.log10(1e+7), n)\r\n\r\nfig, axes = plt.subplots(2, 1)\r\n\r\ntcs = axes[0].tricontourf(\r\n x, y, z,\r\n norm=matplotlib.colors.LogNorm(vmin=z.min(), vmax=z.max()),\r\n)\r\ncbar = fig.colorbar(tcs, ax=axes[0])\r\n\r\ntcs = axes[1].tricontourf(\r\n x, y, z,\r\n locator=matplotlib.ticker.LogLocator(),\r\n)\r\ncbar = fig.colorbar(tcs, ax=axes[1])\r\n\r\nplt.savefig('test.png')\r\n```\r\n\r\n\r\n### Actual outcome\r\n\r\nHere is the outcome of the above in Matplotlib 3.5.0 or 3.6.0 (the results are identical). The image properly shows logarithmic values, and the colorbar ticks are in log scale as well, but the colorbar tick labels are not written using scientific notation. One major drawback is that all tics but the highest two gets written as `0.00`, while they are really `0.001`, `0.0001`, etc.\r\n\r\n\r\n\r\n### Expected outcome\r\n\r\nSame as above but run with Matplotlib 3.4.3. Both methods work to produce scientific notation, as desired.\r\n\r\n\r\n\r\n### Operating system\r\n\r\nLinux Mint 20\r\n\r\n### Matplotlib Version\r\n\r\nAs described above\r\n\r\n### Matplotlib Backend\r\n\r\nAgg and Qt5Agg\r\n\r\n### Python version\r\n\r\n3.8.5 and 3.9.9\r\n\r\n\r\n### Installation\r\n\r\nfrom source (.tar.gz)","author":{"url":"https://github.com/jmd-dk","@type":"Person","name":"jmd-dk"},"datePublished":"2022-09-24T23:27:24.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/24002/matplotlib/issues/24002"}
| 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:fbcccc7e-69f1-fbf2-66c2-5353a137ac88 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B5C2:1DCECA:4AF31:6AB92:6A50ED46 |
| html-safe-nonce | 824c271d5e1ff1a2632bca919b355c713f4b76a936ccf112918f3bff9dbd28c2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNUMyOjFEQ0VDQTo0QUYzMTo2QUI5Mjo2QTUwRUQ0NiIsInZpc2l0b3JfaWQiOiIyMDAzODgwNjE5Mzc4MDExNDYyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 4ef571232dad9fefa57cba1e5d8ecb4dd275c58de53d5ae960932312f6c096ed |
| hovercard-subject-tag | issue:1384840230 |
| 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/24002/issue_layout |
| twitter:image | https://opengraph.githubassets.com/288e02ab9d11de8af53298810ea6740e00e665310b4aa71ab8b98d36a3ff70bf/matplotlib/matplotlib/issues/24002 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/288e02ab9d11de8af53298810ea6740e00e665310b4aa71ab8b98d36a3ff70bf/matplotlib/matplotlib/issues/24002 |
| og:image:alt | Bug summary When using logarithmic scaling of the data with 2D plots, the ticks for the colorbar are not written in scientific notation. Prior to Matplotlib 3.5.0 (e.g. 3.4.3), scientific notation ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jmd-dk |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5266e58c17a510c403505cc811606465e90a881d2007ee7df1c4800d5c659838 |
| 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 | 5ec60191a48933536a90c8a19f47142fcd0d4739 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width