Title: Remove()ing a shared axes prevents the remaining axes from using unit-provided formatters · Issue #12853 · matplotlib/matplotlib · GitHub
Open Graph Title: Remove()ing a shared axes prevents the remaining axes from using unit-provided formatters · Issue #12853 · matplotlib/matplotlib
X Title: Remove()ing a shared axes prevents the remaining axes from using unit-provided formatters · Issue #12853 · matplotlib/matplotlib
Description: Consider from pylab import * from datetime import date fig, axs = plt.subplots(1, 2, sharex=True) axs[1].remove() axs[0].plot([date(2000, 1, 1), date(2000, 2, 1)], [0, 1]) plt.show() One gets i.e. the call to axs[1].remove() prevented th...
Open Graph Description: Consider from pylab import * from datetime import date fig, axs = plt.subplots(1, 2, sharex=True) axs[1].remove() axs[0].plot([date(2000, 1, 1), date(2000, 2, 1)], [0, 1]) plt.show() One gets i.e. ...
X Description: Consider from pylab import * from datetime import date fig, axs = plt.subplots(1, 2, sharex=True) axs[1].remove() axs[0].plot([date(2000, 1, 1), date(2000, 2, 1)], [0, 1]) plt.show() One gets i.e. ...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/12853
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Remove()ing a shared axes prevents the remaining axes from using unit-provided formatters","articleBody":"Consider\r\n```\r\nfrom pylab import *\r\nfrom datetime import date\r\n\r\nfig, axs = plt.subplots(1, 2, sharex=True)\r\naxs[1].remove()\r\naxs[0].plot([date(2000, 1, 1), date(2000, 2, 1)], [0, 1])\r\nplt.show()\r\n```\r\n\r\nOne gets\r\n\r\n\r\ni.e. the call to `axs[1].remove()` prevented the axs[0] from acquiring the correct tick formatter and locator.\r\n\r\nInterestingly, using `fig.delaxes(axs[1])` doesn't exhibit the same bug.\r\n\r\nLooks like the problem comes from\r\n```\r\n def _remove_ax(self, ax):\r\n def _reset_loc_form(axis):\r\n axis.set_major_formatter(axis.get_major_formatter())\r\n axis.set_major_locator(axis.get_major_locator())\r\n axis.set_minor_formatter(axis.get_minor_formatter())\r\n axis.set_minor_locator(axis.get_minor_locator())\r\n\r\n def _break_share_link(ax, grouper):\r\n siblings = grouper.get_siblings(ax)\r\n if len(siblings) \u003e 1:\r\n grouper.remove(ax)\r\n for last_ax in siblings:\r\n if ax is not last_ax:\r\n return last_ax\r\n return None\r\n\r\n self.delaxes(ax)\r\n last_ax = _break_share_link(ax, ax._shared_y_axes)\r\n if last_ax is not None:\r\n _reset_loc_form(last_ax.yaxis)\r\n\r\n last_ax = _break_share_link(ax, ax._shared_x_axes)\r\n if last_ax is not None:\r\n _reset_loc_form(last_ax.xaxis)\r\n```\r\nwhere the call to `set_major_formatter` (etc.), which basically call `formatter.set_axis(axis)` (to update the axis seen by the formatter) also make Matplotlib believe that we had a user-provided formatter (isDefault_majloc = False, etc.) which should not be overridden by the unit framework.\r\n\r\nmpl master (ca. 3.0.2)","author":{"url":"https://github.com/anntzer","@type":"Person","name":"anntzer"},"datePublished":"2018-11-20T18:28:03.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/12853/matplotlib/issues/12853"}
| 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:62c1c4eb-bf9c-3155-79e7-ebfdf8ce22ed |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A53E:C4B40:26095F5:373B998:6A55089F |
| html-safe-nonce | 509ac25f24af4804782acbe55ed1b7b98652bcffee0dd8f177026e62a0166ae3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNTNFOkM0QjQwOjI2MDk1RjU6MzczQjk5ODo2QTU1MDg5RiIsInZpc2l0b3JfaWQiOiI1MTQ2MDgzMDYxMTEzNjIwNjQwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | d01dc25adf2e49bc7a958d33ab20ec3caecd130fa19b34a3135d14d1bf8ffdc8 |
| hovercard-subject-tag | issue:382793927 |
| 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/12853/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e2995d92814635ac1c5354ab63efef15527aa54bfd95de34bff485d44eb01b9f/matplotlib/matplotlib/issues/12853 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e2995d92814635ac1c5354ab63efef15527aa54bfd95de34bff485d44eb01b9f/matplotlib/matplotlib/issues/12853 |
| og:image:alt | Consider from pylab import * from datetime import date fig, axs = plt.subplots(1, 2, sharex=True) axs[1].remove() axs[0].plot([date(2000, 1, 1), date(2000, 2, 1)], [0, 1]) plt.show() One gets i.e. ... |
| 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 | eae2aab99907699a22d2c8449aa683ca74454fca87211b98f7c7b722086b2839 |
| 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 | 6a35ab858be185cd86d12b93a43bccf34e8d8536 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width