-
Notifications
You must be signed in to change notification settings - Fork 368
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add functionality for correct transforms in ax.annotate #2065
Conversation
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 think this looks like a reasonable approach.
For the tests, I would suggest combining them all into one with the different cases pointing to different positions, or parameterizing over the transforms with pytest.mark.parametrize()
, I'm not sure we need a lot of projections to be tested, more so the points/transforms being moved around.
One thing I don't see is the explicit "data" case? If I'm following correctly, that should be the same as the transform passed into the annotate call, and if there is none, default to the map projection.
It might be good to also test that supplying different transforms for xycoords
and textcoords
works as expected too, and we aren't accidentally only using one of them.
change wording in test docstring Co-authored-by: Greg Lucas <greg.m.lucas@gmail.com>
fix comment typo Co-authored-by: Greg Lucas <greg.m.lucas@gmail.com>
@greglucas Thanks for the input. Consolidated the tests and added a couple permutations of providing different CRS transforms to |
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.
Looking good. Just a few minor comments. I like the combinations you chose for the tests.
move offset coord annotation oustide of map
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.
Looks good to me, just one minor comment left about removing the parametrize
now that we're only using one projection (sorry about sending you down that path!).
yeah, no worries. It was a simple addition and a simple removal. |
Thank you for contributing this, @abrammer! Hope to see you around again. |
fixes #1720
Rationale
Annotate has been "broken" for quite some time (https://stackoverflow.com/questions/25416600/why-the-annotate-worked-unexpected-here-in-cartopy), and while the work around is somewhat simple, fixing it to be more intuitive also seems fairly straight forward. Also recently raised in the open issue #1720 which spurred me on to open this PR.
I'm not particularly aware of underlying stuff here or if this is the "correct" way to fix it, but it seems like a relatively simple fix.
Implications
ax.annotate
will function like most other GeoAxes.methods, but previous work arounds will continue to work.Examples
added a couple simple tests which exemplify the various annotate transform configurations.
Example annotated maps: