Title: ENH add an inset_axes to the axes class by jklymak · Pull Request #11026 · matplotlib/matplotlib · GitHub
Open Graph Title: ENH add an inset_axes to the axes class by jklymak · Pull Request #11026 · matplotlib/matplotlib
X Title: ENH add an inset_axes to the axes class by jklymak · Pull Request #11026 · matplotlib/matplotlib
Description: PR Summary and we are back to inset_axes.... @efiring suggested just going back to inset_axes. Since that was what we started with, I didn't object. The original argument for the longer name was if the API was to include a loc='SW' API, instead of the bounds API I've used here. Thats still possible by type-checking the bounds argument. EDIT: Name bikeshedding: Proposal after comments below: Axes.inset_axes_from_bounds Axes.indicate_inset_bounds Axes.indicate_inset_zoom rect was too ambiguous, lbwh too obscure, bounds is already used for bboxes (as is extents for lbrt)... Comments on names still welcome... Old PR descr Adds ax.inset_axes_from_rect. Pretty straight forward, but note that the transData one moves under zoom and pan. Note that I chose not to go with the bbox_to_anchor, and loc approach. I understand that stuff, but it seems needlessly complicated. Maybe as a refinement. import matplotlib.pyplot as plt fig, ax = plt.subplots() ax.plot(range(10)) axin1 = ax.inset_axes_from_rect([0.8, 0.1, 0.15, 0.15]) axin2 = ax.inset_axes_from_rect([5, 7, 2.3, 2.3], transform=ax.transData) plt.show() Getting closer: This is a duplication of https://matplotlib.org/gallery/axes_grid1/inset_locator_demo2.html#sphx-glr-gallery-axes-grid1-inset-locator-demo2-py import matplotlib.pyplot as plt import numpy as np def get_demo_image(): from matplotlib.cbook import get_sample_data import numpy as np f = get_sample_data("axes_grid/bivariate_normal.npy", asfileobj=False) z = np.load(f) # z is a numpy array of 15x15 return z, (-3, 4, -4, 3) fig, ax = plt.subplots(figsize=[5, 4], constrained_layout=True) Z, extent = get_demo_image() Z2 = np.zeros([150, 150], dtype="d") ny, nx = Z.shape Z2[30:30 + ny, 30:30 + nx] = Z # extent = [-3, 4, -4, 3] ax.imshow(Z2, extent=extent, interpolation="nearest", origin="lower") axins = ax.inset_axes_from_rect([0.5, 0.5, 0.47, 0.47]) axins.imshow(Z2, extent=extent, interpolation="nearest", origin="lower") # sub region of the original image x1, x2, y1, y2 = -1.5, -0.9, -2.5, -1.9 axins.set_xlim(x1, x2) axins.set_ylim(y1, y2) axins.set_xticklabels('') axins.set_yticklabels('') ax.zoom_inset_indicator(axins) fig.canvas.draw() plt.show() EDIT: methods renamed inset_axes_rect to allow other APIs in the future. PR Checklist Has Pytest style unit tests Code is PEP 8 compliant New features are documented, with examples if plot related Documentation is sphinx and numpydoc compliant Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there) Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way
Open Graph Description: PR Summary and we are back to inset_axes.... @efiring suggested just going back to inset_axes. Since that was what we started with, I didn't object. The original argument for the longer name w...
X Description: PR Summary and we are back to inset_axes.... @efiring suggested just going back to inset_axes. Since that was what we started with, I didn't object. The original argument for the longer na...
Opengraph URL: https://github.com/matplotlib/matplotlib/pull/11026
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:c4789238-4d84-a9be-c37e-e9e71ba8c2da |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | B3EE:367C3D:467DDF:5F1FD2:6A52F2F0 |
| html-safe-nonce | 448e432f0a7071788e44c9ccb6908fe51e3c71ed8340db8a49c36d9d47c07703 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCM0VFOjM2N0MzRDo0NjdEREY6NUYxRkQyOjZBNTJGMkYwIiwidmlzaXRvcl9pZCI6Ijg4Njg4NDYzNDI2MDIxNTg4MzIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | b8fee307eb1e52f3f329dd0bbea855bc75c0029a3122a170e450cd6c4009194d |
| hovercard-subject-tag | pull_request:180791803 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/matplotlib/matplotlib/pull/11026/files |
| twitter:image | https://avatars.githubusercontent.com/u/1562854?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/1562854?s=400&v=4 |
| og:image:alt | PR Summary and we are back to inset_axes.... @efiring suggested just going back to inset_axes. Since that was what we started with, I didn't object. The original argument for the longer name w... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| diff-view | unified |
| 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 full-width |
| disable-turbo | true |
| 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