Title: [Bug]: inset_axes position same as parent axes position. Breaks indicate_axes_zoom · Issue #22606 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: inset_axes position same as parent axes position. Breaks indicate_axes_zoom · Issue #22606 · matplotlib/matplotlib
X Title: [Bug]: inset_axes position same as parent axes position. Breaks indicate_axes_zoom · Issue #22606 · matplotlib/matplotlib
Description: Bug summary An inset axes created using mpl_toolkits.axes_grid1.inset_locator.inset_axes seems to inherit its position from the parent axes. This prevents any connection lines being drawn by indicate_inset_zoom showing up, as their "visi...
Open Graph Description: Bug summary An inset axes created using mpl_toolkits.axes_grid1.inset_locator.inset_axes seems to inherit its position from the parent axes. This prevents any connection lines being drawn by indica...
X Description: Bug summary An inset axes created using mpl_toolkits.axes_grid1.inset_locator.inset_axes seems to inherit its position from the parent axes. This prevents any connection lines being drawn by indica...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/22606
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: inset_axes position same as parent axes position. Breaks indicate_axes_zoom","articleBody":"### Bug summary\r\n\r\nAn inset axes created using `mpl_toolkits.axes_grid1.inset_locator.inset_axes` seems to inherit its position from the parent axes. This prevents any connection lines being drawn by `indicate_inset_zoom` showing up, as [their \"visible\" attributes depend on the result of get_position](https://github.com/matplotlib/matplotlib/blob/710fce3df95e22701bd68bf6af2c8adbc9d67a79/lib/matplotlib/axes/_axes.py#L467-L479).\r\n\r\n\r\n\r\n### Code for reproduction\r\n\r\n```python\r\n# Adapted from the gallery example, but replacing the axes method with the function from toolkits.\r\n\r\nfrom matplotlib import cbook\r\nimport matplotlib.pyplot as plt\r\nfrom mpl_toolkits.axes_grid1.inset_locator import inset_axes\r\nimport numpy as np\r\n\r\n\r\ndef get_demo_image():\r\n z = cbook.get_sample_data(\"axes_grid/bivariate_normal.npy\", np_load=True)\r\n # z is a numpy array of 15x15\r\n return z, (-3, 4, -4, 3)\r\n\r\nfig, ax = plt.subplots(figsize=[5, 4])\r\n\r\n# make data\r\nZ, extent = get_demo_image()\r\nZ2 = np.zeros((150, 150))\r\nny, nx = Z.shape\r\nZ2[30:30+ny, 30:30+nx] = Z\r\n\r\nax.imshow(Z2, extent=extent, origin=\"lower\")\r\n\r\n# inset axes....\r\naxins = inset_axes(ax, width=\"50%\", height=\"50%\")\r\naxins.imshow(Z2, extent=extent, origin=\"lower\")\r\n\r\n# sub region of the original image\r\nx1, x2, y1, y2 = -1.5, -0.9, -2.5, -1.9\r\naxins.set_xlim(x1, x2)\r\naxins.set_ylim(y1, y2)\r\naxins.set_xticklabels([])\r\naxins.set_yticklabels([])\r\n\r\nprint(\"main axes position:\", ax.get_position())\r\nprint(\"inset axes position:\", axins.get_position())\r\n\r\nax.indicate_inset_zoom(axins, edgecolor=\"black\")\r\n\r\nplt.show()\r\n```\r\n\r\n\r\n### Actual outcome\r\n\r\n```\r\nmain axes position: Bbox(x0=0.20449999999999996, y0=0.10999999999999999, x1=0.8205, y1=0.88)\r\ninset axes position: Bbox(x0=0.20449999999999996, y0=0.10999999999999999, x1=0.8205, y1=0.88)\r\n```\r\n\r\n\r\n\r\n\r\n### Expected outcome\r\n\r\nPlot should have connecting lines, similar to the [zoom region inset axes](https://matplotlib.org/stable/gallery/subplots_axes_and_figures/zoom_inset_axes.html#sphx-glr-gallery-subplots-axes-and-figures-zoom-inset-axes-py) gallery example.\r\n\r\n### Additional information\r\n\r\n_No response_\r\n\r\n### Operating system\r\n\r\nRHEL\r\n\r\n### Matplotlib Version\r\n\r\n3.5.1\r\n\r\n### Matplotlib Backend\r\n\r\nTKAgg\r\n\r\n### Python version\r\n\r\n3.10.2\r\n\r\n### Jupyter version\r\n\r\n_No response_\r\n\r\n### Installation\r\n\r\nconda","author":{"url":"https://github.com/rcomer","@type":"Person","name":"rcomer"},"datePublished":"2022-03-05T16:40:39.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/22606/matplotlib/issues/22606"}
| 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:4160e89a-a415-8862-2977-197958d6abae |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E82C:18EE7E:478E7:5F835:6A525F81 |
| html-safe-nonce | a21f8ebeacfa548c11196b8a01b14f2a779135ae30cd014030e5784548673a3c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFODJDOjE4RUU3RTo0NzhFNzo1RjgzNTo2QTUyNUY4MSIsInZpc2l0b3JfaWQiOiI2NDM3OTYzNTAzODIzMzgwMzUzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | f7a26c0a3f748b1bdfb1288f3eab1cef405770acb4114a330d9453ce6cd50e01 |
| hovercard-subject-tag | issue:1160394920 |
| 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/22606/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ae3e72ff73dbb10f64053f6186908d84124e3596cea7e1d2cdbab481e9636656/matplotlib/matplotlib/issues/22606 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ae3e72ff73dbb10f64053f6186908d84124e3596cea7e1d2cdbab481e9636656/matplotlib/matplotlib/issues/22606 |
| og:image:alt | Bug summary An inset axes created using mpl_toolkits.axes_grid1.inset_locator.inset_axes seems to inherit its position from the parent axes. This prevents any connection lines being drawn by indica... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | rcomer |
| 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 | 7aed05249554b889eb33d002851a973eebcc7e91 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width