Title: [ENH]: minor ticks for symlog norms (with integer base) · Issue #25994 · matplotlib/matplotlib · GitHub
Open Graph Title: [ENH]: minor ticks for symlog norms (with integer base) · Issue #25994 · matplotlib/matplotlib
X Title: [ENH]: minor ticks for symlog norms (with integer base) · Issue #25994 · matplotlib/matplotlib
Description: Problem As of matplotlib 3.7.1, matplotlib.colors.SymLogNorm doesn't produce any minor tick (that doesn't overlap with major ticks). I understand that default minor tick locations are absolutely not obvious in the general case and, where...
Open Graph Description: Problem As of matplotlib 3.7.1, matplotlib.colors.SymLogNorm doesn't produce any minor tick (that doesn't overlap with major ticks). I understand that default minor tick locations are absolutely no...
X Description: Problem As of matplotlib 3.7.1, matplotlib.colors.SymLogNorm doesn't produce any minor tick (that doesn't overlap with major ticks). I understand that default minor tick locations are absol...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/25994
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[ENH]: minor ticks for symlog norms (with integer base)","articleBody":"### Problem\r\n\r\nAs of matplotlib 3.7.1, `matplotlib.colors.SymLogNorm` doesn't produce any minor tick (that doesn't overlap with major ticks). I understand that default minor tick locations are absolutely not obvious in the general case and, where the log base can be any real number, however, I think there's a case to be had regarding the special (and very useful) case of *integer* log bases (10 and 2 are probably among the most useful bases all domains considered), in which the interval between two major ticks n and n+1 can be divided by the interval between ticks n-1 and n (where n+1 is farthest from 0).\r\n\r\nIf fact `matplotlib.colors.LogNorm` uses log10 and produces minorticks by default. The difference in behaviour is perhaps best illustrated in a case where everything else is identical\r\n\r\n```python\r\nimport numpy as np\r\nimport matplotlib.pyplot as plt\r\nfrom matplotlib.colors import SymLogNorm, LogNorm\r\n\r\nprng = np.random.RandomState(0)\r\ndata = 50 * (prng.random_sample((10, 10)))\r\n\r\nfig, axs = plt.subplots(ncols=2, figsize=(10,3))\r\n\r\nfor ax, norm in zip(axs, [LogNorm(), SymLogNorm(base=10, linthresh=1)]):\r\n im = ax.imshow(data, cmap=\"viridis_r\", norm=norm)\r\n cb = fig.colorbar(im, ax=ax)\r\n cb.minorticks_on()\r\n\r\nsfile = \"/tmp/test.png\"\r\nprint(f\"saving to {sfile}\")\r\nfig.savefig(sfile)\r\n```\r\n\r\n\r\nHere's my attempt to reproduce what's happening internally (within `cb.minorticks_on()`) with a more minimal example\r\n```python\r\nimport matplotlib.ticker as mticker\r\n\r\nlog_t = mticker.LogLocator(base=10, subs=None)\r\nsymlog_t = mticker.SymmetricalLogLocator(linthresh=1, base=10, subs=None)\r\n\r\nprint(log_t.tick_values(vmin=1, vmax=100))\r\nprint(symlog_t.tick_values(vmin=1, vmax=100))\r\n```\r\noutputs\r\n```\r\n[2.e-01 3.e-01 4.e-01 5.e-01 6.e-01 7.e-01 8.e-01 9.e-01 2.e+00 3.e+00\r\n 4.e+00 5.e+00 6.e+00 7.e+00 8.e+00 9.e+00 2.e+01 3.e+01 4.e+01 5.e+01\r\n 6.e+01 7.e+01 8.e+01 9.e+01 2.e+02 3.e+02 4.e+02 5.e+02 6.e+02 7.e+02\r\n 8.e+02 9.e+02 2.e+03 3.e+03 4.e+03 5.e+03 6.e+03 7.e+03 8.e+03 9.e+03]\r\n[ 1. 10. 100.]\r\n```\r\n\r\nI think that it is reasonable to expect `SymmetricalLogLocator` and `LogLocator` to produce identica ticks in this case (for values above `linthresh`), and this behaviour could be generalised to any integer base.\r\n\r\n### Proposed solution\r\n\r\nAt the moment I don't have a working patch for this. What I do not understand is how major ticks are sorted out from minor ticks in the case `LogLocator`. With a better understanding of the internals I'm willing to bet that the behaviour I expect should be easy to implement, and I'm more than willing to contribute it, but I may need some guidance.","author":{"url":"https://github.com/neutrinoceros","@type":"Person","name":"neutrinoceros"},"datePublished":"2023-05-28T11:14:38.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/25994/matplotlib/issues/25994"}
| 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:a7963186-6f80-b27e-62bb-6eca61954e07 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 95A6:191073:A5533E:DD2047:6A52975E |
| html-safe-nonce | 87712b022c407a0e0a517b3b857a9111f2c28354ebdd74c581fb81cd45e314a6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NUE2OjE5MTA3MzpBNTUzM0U6REQyMDQ3OjZBNTI5NzVFIiwidmlzaXRvcl9pZCI6IjQyMDQ2MDQ2NzMzODk0MDE5NTAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 2c9f1b3f5a2909cb38df1be8e9dda4311e23ee49027cb201935b481af9ac2a8e |
| hovercard-subject-tag | issue:1729400493 |
| 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/25994/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8a923026b90fbe947e2d5889937cd7aa9f68e63b782035f6ab28c2a47886d68e/matplotlib/matplotlib/issues/25994 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8a923026b90fbe947e2d5889937cd7aa9f68e63b782035f6ab28c2a47886d68e/matplotlib/matplotlib/issues/25994 |
| og:image:alt | Problem As of matplotlib 3.7.1, matplotlib.colors.SymLogNorm doesn't produce any minor tick (that doesn't overlap with major ticks). I understand that default minor tick locations are absolutely no... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | neutrinoceros |
| 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