Title: [ENH]: Compute ticks of log scaled axes a bit better? · Issue #29414 · matplotlib/matplotlib · GitHub
Open Graph Title: [ENH]: Compute ticks of log scaled axes a bit better? · Issue #29414 · matplotlib/matplotlib
X Title: [ENH]: Compute ticks of log scaled axes a bit better? · Issue #29414 · matplotlib/matplotlib
Description: Problem Taken from here, I found the following ticks (from plt.semilogy([1.5, 50])): Not informative enough. I wish there was an easy way to set_minor_formatter such that say e.g 2x10^0, 3x10^0 would have been displayed. I tried to use (...
Open Graph Description: Problem Taken from here, I found the following ticks (from plt.semilogy([1.5, 50])): Not informative enough. I wish there was an easy way to set_minor_formatter such that say e.g 2x10^0, 3x10^0 wou...
X Description: Problem Taken from here, I found the following ticks (from plt.semilogy([1.5, 50])): Not informative enough. I wish there was an easy way to set_minor_formatter such that say e.g 2x10^0, 3x10^0 wou...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/29414
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[ENH]: Compute ticks of log scaled axes a bit better?","articleBody":"### Problem\n\nTaken from [here](https://github.com/matplotlib/matplotlib/issues/8768/#issuecomment-889516769), I found the following ticks (from `plt.semilogy([1.5, 50])`):\r\n\r\n\r\n\r\nNot informative enough. I wish there was an easy way to `set_minor_formatter` such that say\te.g `2x10^0`, `3x10^0` would have been displayed. I tried to use (full MWE this time):\r\n\r\n```python\r\nimport matplotlib.pyplot as plt\r\nfrom matplotlib import ticker\r\n\r\nplt.semilogy([1.5, 50])\r\nplt.gca().yaxis.set_minor_formatter(ticker.LogFormatter(base=10, labelOnlyBase=True))\r\nplt.show()\r\n```\r\n\r\nBut it changed nothing. OTH I was capable to obtain my desired output with:\r\n\r\n```python\r\n#!/usr/bin/env python\r\n\r\nimport numpy as np\r\n\r\nimport matplotlib.pyplot as plt\r\nfrom matplotlib import ticker\r\n\r\nplt.semilogy([1.5, 50])\r\ndef get_minor_tick_string(x, pos):\r\n b = np.floor(np.log10(x)).astype(int)\r\n p = pos % 8\r\n if p \u003c 3:\r\n return f\"${p+2}\\\\cdot 10^{b}$\"\r\n else:\r\n return \"\"\r\nplt.gca().yaxis.set_minor_formatter(get_minor_tick_string)\r\nplt.show()\r\n```\r\n\r\nBut I'm sure it is not very versatile. It produces:\r\n\r\n\r\n\r\nWhich is not bad.\n\n### Proposed solution\n\nI'd like to first explain in the docs / fix the behavior of `set_minor_formatter(ticker.LogFormatter(base=10, labelOnlyBase=True))`. 2ndly, I'd like to discuss the possibility of adding tick labels as shown above, because I think I'm not the only one that was not satisfied by this default behavior.","author":{"url":"https://github.com/doronbehar","@type":"Person","name":"doronbehar"},"datePublished":"2025-01-06T18:52:37.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/29414/matplotlib/issues/29414"}
| 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:2896f35d-215a-572e-1c6c-13e339912041 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 88D8:27934D:2ADAAB:39BBE8:6A5228C0 |
| html-safe-nonce | 2c390328d00c7549b87407327c2deb830e73c0d509a9c9ccb53d5239b266400a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4OEQ4OjI3OTM0RDoyQURBQUI6MzlCQkU4OjZBNTIyOEMwIiwidmlzaXRvcl9pZCI6IjM5MzY5MTkxNDAxNTQwOTE3MTIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 25683b914211817db55df2960c8a67c6f6a3adcda7a5d5558d4753c74e4f4870 |
| hovercard-subject-tag | issue:2771246542 |
| 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/29414/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a9c0024c32a2a8235cb865c1f1983d29c608a3b8a2c2ed18d8c5736175a131bb/matplotlib/matplotlib/issues/29414 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a9c0024c32a2a8235cb865c1f1983d29c608a3b8a2c2ed18d8c5736175a131bb/matplotlib/matplotlib/issues/29414 |
| og:image:alt | Problem Taken from here, I found the following ticks (from plt.semilogy([1.5, 50])): Not informative enough. I wish there was an easy way to set_minor_formatter such that say e.g 2x10^0, 3x10^0 wou... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | doronbehar |
| 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