Title: [Bug]: twinx and twiny ignores previous set_position · Issue #21409 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: twinx and twiny ignores previous set_position · Issue #21409 · matplotlib/matplotlib
X Title: [Bug]: twinx and twiny ignores previous set_position · Issue #21409 · matplotlib/matplotlib
Description: Bug summary If I manually set the position of an Axes, then call twinx or twiny, the new twinned Axes appears in the original position of the parent Axes, not in the new position. Code for reproduction import matplotlib.pyplot as plt fig...
Open Graph Description: Bug summary If I manually set the position of an Axes, then call twinx or twiny, the new twinned Axes appears in the original position of the parent Axes, not in the new position. Code for reproduc...
X Description: Bug summary If I manually set the position of an Axes, then call twinx or twiny, the new twinned Axes appears in the original position of the parent Axes, not in the new position. Code for reproduc...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/21409
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: twinx and twiny ignores previous set_position","articleBody":"### Bug summary\n\nIf I manually set the position of an Axes, then call twinx or twiny, the new twinned Axes appears in the original position of the parent Axes, not in the new position.\n\n### Code for reproduction\n\n```python\nimport matplotlib.pyplot as plt\r\nfig, ax = plt.subplots()\r\nax.set_position([0.2,0.2,0.5,0.5])\r\nax2 = ax.twinx()\r\nplt.show()\n```\n\n\n### Actual outcome\n\n\r\n\r\nI note that `ax.get_position(original=True)` and `ax.get_position(original=False)` both give the same answer.\r\nI also note that the same issue occurs for `ax.twiny()`.\n\n### Expected outcome\n\n\r\nThis expected outcome can be obtained by adding the line\r\n```python3\r\nax2.set_position(ax.get_position())\r\n```\r\nafter calling `ax2=ax.twinx()`. Alternatively, it can be obtained by calling `ax.set_position` after calling `ax.twinx`.\r\nHowever, I would expect `twinx` to automatically inherit the position of the parent Axes, rather than draw the new Axes in an unrelated location.\n\n### Operating system\n\nWindows 10\n\n### Matplotlib Version\n\n3.4.2\n\n### Matplotlib Backend\n\nTkAgg\n\n### Python version\n\n3.9.4\n\n### Jupyter version\n\n_No response_\n\n### Other libraries\n\n_No response_\n\n### Installation\n\npip\n\n### Conda channel\n\n_No response_","author":{"url":"https://github.com/bfield1","@type":"Person","name":"bfield1"},"datePublished":"2021-10-21T02:05:36.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/21409/matplotlib/issues/21409"}
| 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:bd856ef3-ad0e-8019-8f92-e95a8797e947 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A558:172D3F:A3F00A:DB5411:6A540383 |
| html-safe-nonce | 57170e92b13549420c2bf53854086681d4cf31c65447c3f3badff833aaf89170 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNTU4OjE3MkQzRjpBM0YwMEE6REI1NDExOjZBNTQwMzgzIiwidmlzaXRvcl9pZCI6IjUxMjk3OTQ4Nzg2Nzk4MTA5NDciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 1a166ae2587c34d5ab35c7cf674f51555a9f2ec5328fc65e0b2ecac6b25236b9 |
| hovercard-subject-tag | issue:1031980414 |
| 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/21409/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0fbbd4af3c70af911e42cac0f0ba734263aa246dc1a77fc4b299a303e4d08013/matplotlib/matplotlib/issues/21409 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0fbbd4af3c70af911e42cac0f0ba734263aa246dc1a77fc4b299a303e4d08013/matplotlib/matplotlib/issues/21409 |
| og:image:alt | Bug summary If I manually set the position of an Axes, then call twinx or twiny, the new twinned Axes appears in the original position of the parent Axes, not in the new position. Code for reproduc... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | bfield1 |
| 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