Title: Interesting things happen when calling cla() on shared axes with log scales · Issue #12819 · matplotlib/matplotlib · GitHub
Open Graph Title: Interesting things happen when calling cla() on shared axes with log scales · Issue #12819 · matplotlib/matplotlib
X Title: Interesting things happen when calling cla() on shared axes with log scales · Issue #12819 · matplotlib/matplotlib
Description: In the plot below, each axes is yaxis-shared with the axes in the same column. In each case, I'll start by setting the top yaxis to use a log-base-2 scale. In the left column, I then call cla() on the top axis. In the right column, I the...
Open Graph Description: In the plot below, each axes is yaxis-shared with the axes in the same column. In each case, I'll start by setting the top yaxis to use a log-base-2 scale. In the left column, I then call cla() on ...
X Description: In the plot below, each axes is yaxis-shared with the axes in the same column. In each case, I'll start by setting the top yaxis to use a log-base-2 scale. In the left column, I then call cla()...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/12819
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Interesting things happen when calling cla() on shared axes with log scales","articleBody":"In the plot below, each axes is yaxis-shared with the axes in the same column.\r\nIn each case, I'll start by setting the top yaxis to use a log-base-2 scale.\r\n\r\n- In the left column, I then call cla() on the *top* axis.\r\n- In the right column, I then call cla() on the *bottom* axis.\r\n\r\nIn every case, the top-left text indicates the scale and formatter used by that axis before the call to cla(), the top-right text indicates the scale and formatter used after the call to cla().\r\n\r\n\r\n\r\nIn column 1, the call to cla() on the top axis reset both the scale to linear and the formatter to the default formatter. On the bottom axis, the scale was not reset, but the formatter was.\r\nIn column 2, the call to cla() on the bottom axis reset the formatter to the default formatter, but did set the scale to log10(!). The top axis had its scale kept and its formatter reset (similarly to column 1 bottom).\r\n\r\nI'm not sure what the correct behavior should be but it's likely not the current one.\r\n\r\nScript:\r\n```\r\nfrom pylab import *\r\n\r\nmem = {}\r\n\r\ndef remember_scale(ax, title_loc):\r\n scale = ax.yaxis._scale\r\n fmt = type(ax.yaxis.get_major_formatter()).__name__\r\n if scale.name == \"linear\":\r\n mem[ax, title_loc] = f\"linear\\n{fmt}\"\r\n elif scale.name == \"log\":\r\n mem[ax, title_loc] = f\"log{scale.base}\\n{fmt}\"\r\n else:\r\n mem[ax, title_loc] = \"oops\"\r\n\r\nfig, axs = plt.subplots(2, 2, sharey=\"col\")\r\n\r\naxs[0, 0].set_yscale(\"log\", basey=2)\r\nremember_scale(axs[0, 0], \"left\")\r\nremember_scale(axs[1, 0], \"left\")\r\naxs[0, 0].cla()\r\nremember_scale(axs[0, 0], \"right\")\r\nremember_scale(axs[1, 0], \"right\")\r\n\r\naxs[0, 1].set_yscale(\"log\", basey=2)\r\nremember_scale(axs[0, 1], \"left\")\r\nremember_scale(axs[1, 1], \"left\")\r\naxs[1, 1].cla()\r\nremember_scale(axs[0, 1], \"right\")\r\nremember_scale(axs[1, 1], \"right\")\r\n\r\nfor (ax, title_loc), scale in mem.items():\r\n ax.set_title(scale, loc=title_loc)\r\n\r\nplt.show()\r\n```\r\n\r\nNoted while reviewing #12818 (digging into https://github.com/matplotlib/matplotlib/pull/12818#discussion_r234024985).\r\n\r\nmpl 3.0.2 / Py3.7 / Arch Linux","author":{"url":"https://github.com/anntzer","@type":"Person","name":"anntzer"},"datePublished":"2018-11-15T23:27:38.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/12819/matplotlib/issues/12819"}
| 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:54b98af6-994e-a4d0-ecd2-bfb7ec2c848c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B964:1CCA14:1553DF:1C8770:6A52E082 |
| html-safe-nonce | 34ea37191841d937c408de91dff939a68ba119ccef6845b057c7914211df34e8 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCOTY0OjFDQ0ExNDoxNTUzREY6MUM4NzcwOjZBNTJFMDgyIiwidmlzaXRvcl9pZCI6IjYyNTg2NTY1OTQ5Njk2ODIwNTAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | db0d4ce5c1d8ed37a688f0f6bd2f8fef2fe63fab45319a54d2c8f658af7d4e70 |
| hovercard-subject-tag | issue:381383050 |
| 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/12819/issue_layout |
| twitter:image | https://opengraph.githubassets.com/017e2b8000c65592311185f21f386dd0a5f82b95d49e626db1b42037d20d8257/matplotlib/matplotlib/issues/12819 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/017e2b8000c65592311185f21f386dd0a5f82b95d49e626db1b42037d20d8257/matplotlib/matplotlib/issues/12819 |
| og:image:alt | In the plot below, each axes is yaxis-shared with the axes in the same column. In each case, I'll start by setting the top yaxis to use a log-base-2 scale. In the left column, I then call cla() on ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | anntzer |
| 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