Title: Add additional minor labels in log axis with a span less than two decades · Issue #4867 · matplotlib/matplotlib · GitHub
Open Graph Title: Add additional minor labels in log axis with a span less than two decades · Issue #4867 · matplotlib/matplotlib
X Title: Add additional minor labels in log axis with a span less than two decades · Issue #4867 · matplotlib/matplotlib
Description: For plots with log axis that have limits of the order or less than two decades, only one label is shown: Which does not give a very good idea of the values of the x axis. Adding labels to the minor ticks results in a mess, including non-...
Open Graph Description: For plots with log axis that have limits of the order or less than two decades, only one label is shown: Which does not give a very good idea of the values of the x axis. Adding labels to the minor...
X Description: For plots with log axis that have limits of the order or less than two decades, only one label is shown: Which does not give a very good idea of the values of the x axis. Adding labels to the minor...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/4867
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add additional minor labels in log axis with a span less than two decades","articleBody":"For plots with log axis that have limits of the order or less than two decades, only one label is shown:\n\n\nWhich does not give a very good idea of the values of the x axis. Adding labels to the minor ticks results in a mess, including non-helpful labels such as `10^{4.30}`:\n\n```\nax.xaxis.set_minor_formatter(ticker.LogFormatterMathtext(labelOnlyBase=False))\n```\n\n\n\nAnd limiting them at `[2,5]*base**i` results in losing all other minor ticks:\n\n```\nax.xaxis.set_minor_locator(ticker.LogLocator(subs=[2,5]))\n```\n\n\n\nThe decimals in the exponent can be resolved using LogFormatter, but it is not a nice representation for axis and requires changing the major formatter to match:\n\n```\nax.xaxis.set_minor_formatter(ticker.LogFormatter(labelOnlyBase=False))\nax.xaxis.set_major_formatter(ticker.LogFormatter())\n```\n\n\n\nFinally, the only way to get them in a consistent manner with the major tick labels, while preserving all minor ticks, is to set them manually, which is far from ideal:\n\n```\nax.xaxis.set_ticklabels([r'$2\\times10^4$','','',r'$5\\times10^4$','','','','', \n r'$2\\times 10^4$','','',r'$5\\times10^4$','','','','',\n r'$2\\times 10^5$','','',r'$5\\times10^5$','','','','',\n ],minor=True)\n```\n\n\n\nI think that there should be a `LogFormatterMathtext` with a `subs` options like the locator, and an option to factors instead of decimal exponents. I will take a look at the `LogFormatterMathtext` and try to modify it in the following days. If it looks good, I would propose to switch to it automatically for axis spanning less than two decades.\n\nNote that this issue has been reported in [a stackoverflow question](http://stackoverflow.com/questions/17165435/matplotlib-show-labels-for-minor-ticks-also) where a custom formatter is proposed as an answer.\nThis is somewhat related to the issue #4730 because the lack of labels is particularly noticeable when the axis is around 0.1,1,10, where it would make a lot of sense to have labels at [0.1,0.2,2,5,20,50]. \n","author":{"url":"https://github.com/zblz","@type":"Person","name":"zblz"},"datePublished":"2015-08-05T09:21:09.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":6},"url":"https://github.com/4867/matplotlib/issues/4867"}
| 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:d44a0e68-d05d-3ce1-facb-cd1cbf3d0762 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D346:2E411E:1805767:207BEF5:6A535C9E |
| html-safe-nonce | fc4c844351b15a6b87cc7bf625ad8367b5e4ccf1cc097b55eea3d2a2c2e1330a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMzQ2OjJFNDExRToxODA1NzY3OjIwN0JFRjU6NkE1MzVDOUUiLCJ2aXNpdG9yX2lkIjoiMzk4NTUzNDkzNDcwOTI4MDMwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 58987149746ef38a3c508eb350f1efcbab23af6c3fa2d72979db56ba8a0bca90 |
| hovercard-subject-tag | issue:99160495 |
| 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/4867/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f2349f5128d5bae8bf8418a93945c00d170f1870701c6e16b7e5bbb35a951432/matplotlib/matplotlib/issues/4867 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f2349f5128d5bae8bf8418a93945c00d170f1870701c6e16b7e5bbb35a951432/matplotlib/matplotlib/issues/4867 |
| og:image:alt | For plots with log axis that have limits of the order or less than two decades, only one label is shown: Which does not give a very good idea of the values of the x axis. Adding labels to the minor... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | zblz |
| 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