GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — `indicate_inset` transform support by rcomer · Pull Request #29174 · matplotlib/matplotlib

Conversation

@rcomer

@rcomer rcomer commented Nov 22, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

PR summary

  1. Corrected the indicate_inset docstring, as we are definitely defaulting to transData.
  2. Currently the ends of the connectors that meet the box do not use the passed transform. So against main, my new image test gives
    main
  3. Set the axes property on the rectangle so that Cartopy transforms will work, and we can do things like
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import cartopy.feature as cfeature

main_map_proj = ccrs.TransverseMercator()
pcarree = ccrs.PlateCarree()

fig, ax = plt.subplots(subplot_kw={"projection": main_map_proj})

ax.set_extent([-50, 15, 50, 70], crs=pcarree)
ax.add_feature(cfeature.OCEAN.with_scale('50m'), facecolor="lightsteelblue", zorder=1,
               edgecolor="k", lw=0.2)

inset_ax = ax.inset_axes((0.05, 0.05, 0.3, 0.3), projection=pcarree)

inset_extent = [-44, -38, 63, 66]
inset_ax.set_extent(inset_extent, crs=pcarree)
inset_ax.add_feature(cfeature.OCEAN, facecolor="lightsteelblue", zorder=1)

ax.indicate_inset_zoom(inset_ax, edgecolor="black", transform=pcarree)

x = [inset_extent[0], inset_extent[1], inset_extent[1], inset_extent[0]]
y = [inset_extent[2], inset_extent[2], inset_extent[3], inset_extent[3]]
for a in ax, inset_ax:
    a.scatter(x, y, c=range(4), s=150, transform=pcarree)

plt.show()

image

PR checklist

  • [n/a] "closes #0000" is in the body of the PR description to link the related issue
  • new and changed code is tested
  • [n/a] Plotting related features are demonstrated in an example
  • [n/a] New Features and API Changes are noted with a directive and release note
  • Documentation complies with general and docstring guidelines

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
rcomer
rcomer commented Nov 22, 2024
View reviewed changes
Comment thread lib/matplotlib/inset.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@rcomer
rcomer marked this pull request as draft November 22, 2024 20:12
@rcomer
rcomer force-pushed the inset-conn-transform branch 2 times, most recently from c8e7643 to ba851c1 Compare November 22, 2024 20:43
rcomer
rcomer commented Nov 22, 2024
View reviewed changes
Comment thread lib/matplotlib/tests/test_inset.py


@image_comparison(['zoom_inset_transform.png'], remove_text=True, style='mpl20',
tol=0.01)

@rcomer rcomer Nov 22, 2024

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MacOS tests need the 0.01 tolerance.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@rcomer
rcomer marked this pull request as ready for review November 22, 2024 21:14
@rcomer rcomer mentioned this pull request Nov 22, 2024
indicate_inset_zoom not working on some projections SciTools/cartopy#2482
Open
@rcomer
rcomer force-pushed the inset-conn-transform branch 2 times, most recently from 470b488 to 0d57221 Compare November 22, 2024 21:52
@rcomer
indicate_inset transform support
95ed490
@rcomer
rcomer force-pushed the inset-conn-transform branch from 0d57221 to 95ed490 Compare November 23, 2024 08:40
rcomer
rcomer commented Nov 23, 2024
View reviewed changes
Comment thread lib/matplotlib/inset.py
# Set axes on the rectangle (required for some external transforms to work) as
# well as the InsetIndicator artist.
self.rectangle.axes = new_axes
artist.Artist.axes.fset(self, new_axes)

@rcomer rcomer Nov 23, 2024

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied the setter logic here from the artist within artist example. I would not have figured it out by myself - thanks @QuLogic for putting it in the example!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
greglucas
greglucas approved these changes Dec 5, 2024
View reviewed changes
@rcomer rcomer mentioned this pull request Dec 17, 2024
Propagate Axes class and kwargs for twinx and twiny #29325
Merged
2 of 5 tasks
QuLogic
QuLogic approved these changes Dec 20, 2024
View reviewed changes
@QuLogic
QuLogic merged commit a3682f3 into matplotlib:main Dec 20, 2024
@QuLogic QuLogic added the topic: transforms and scales label Dec 20, 2024
@QuLogic QuLogic added this to the v3.11.0 milestone Dec 20, 2024
@rcomer
rcomer deleted the inset-conn-transform branch December 20, 2024 08:08
@moss-xyz moss-xyz mentioned this pull request Mar 9, 2025
[Bug]: Inset Axes Failing for Geographic Plot #29720
Closed
@rcomer rcomer mentioned this pull request Aug 4, 2025
[Bug]: offset in transformed ellipse vertices #30165
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@QuLogic QuLogic QuLogic approved these changes
@greglucas greglucas greglucas approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

topic: transforms and scales

Projects

None yet

Milestone

v3.11.0

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@rcomer @QuLogic @greglucas
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.