Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Axes.inset_axes: enable Axes subclass creation#22608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Looks like I have brokenone test consistently across platforms. I will have to come back to this another day. |
Inset axes are explicitly children of their parent axes so please don't also add the figure as a parent. I'm not quite sure what the best way to get a projection into an inset_axes is... |
This seems like a useful thing to have available in some form. Might be worth having a look at#22060 and whetherhttps://github.com/matplotlib/matplotview would work with GeoAxes too... Ahh, the axes being a child of the figure or not would actually explain why mpl_toolkit inset_axes warn with
The easiest way might be to allow matplotlib/lib/mpl_toolkits/axes_grid1/inset_locator.py Lines 380 to 385 ine75b529
However, there might be some more surgery needed outside of AxesGrid to support the projection or other keyword args. matplotlib/lib/matplotlib/figure.py Lines 535 to 538 in09b17b1
|
Thanks for the feedback. I did have a hunch that it couldn't really be this simple!
I'm afraid I don't have the background knowledge to understand this. Is there somewhere I can read up on the matplotlib parent/child relationships and why they matter? I guess the comment about
Looks useful - thanks! I will have a play with that at some point.
I'm not so keen on that API as it seems inconsistent with how the user is usually encouraged to create their Axes instances. But I guess it was done in those other functions for a reason. Anyway it seems that whatever the answer is, it's not this. So for now I will just close this. |
@rcomer, maybe convert this to an issue? I think it is reasonable to ask that inset_axes accepts projections, I'm just not sure off the top of my head how to do it (I have limited Matplotlib (and internet) bandwidth at the moment. |
Issue now at#22630. Thanks! |
The important functionality seems to be contained within |
@rcomer, did this not work? It looks like something similarshould work, and it is certainly reasonable functionality... |
In general, Matplotlib does not have a "reserve an issue" policy, and this PR predates@mylasem 's comment. I think they should work within the context of this PR if at all possible. |
OK, since@mylasem has not commented further and I had some time, I have:
|
lib/matplotlib/tests/test_axes.py Outdated
@@ -6614,6 +6614,30 @@ def test_zoom_inset(): | |||
axin1.get_position().get_points(), xx, rtol=1e-4) | |||
def test_inset_polar(): | |||
from matplotlib.projections.polar import PolarAxes |
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 imported the class within the test as I noticed another test in this module does that. If that's not necessary, then I think we could parametrize these three tests into one.
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 do not see any reason to do this, I think pulling all of the imports to the top is OK.
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 moved the imports to the top, but in the end couldn't convince myself it was worth parametrizing the two small tests that are still the same: since they're so small there isn'tmuch repetition going on and I suspect readability is better as they are than with a parametrized version.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
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 am 👍 with this going in as-is.
Moving to the mpl20 style would be good as would refactoring the test, but neither is worth holding up the PR over.
Thanks@tacaswell, I am happy to follow those up tomorrow when I am back at my keyboard. Should I also squash the commits down to one? |
Yes please (and if you replace the image CI without squashing CI will fail). |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Thanks All for your guidance! |
Uh oh!
There was an error while loading.Please reload this page.
PR Summary
Closes#22630
Modify
Axes.inset_axes
so it can accept thepolar
,projection
andaxes_class
keywords, and therefore return subclasses ofAxes
. My target use-case is with Cartopy, so we can now adaptthis gallery example to do something likePR Checklist
Tests and Styling
pytest
passes).I'm unsure what extra tests should be added for this. Advice welcome!flake8-docstrings
and runflake8 --docstring-convention=all
).Documentation
doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).