Skip to content

Add corner coordinate helper methods to Ellipse/Rectangle#21977

Merged
QuLogic merged 1 commit intomatplotlib:mainfrom
dstansby:patch-helpers
Jan 5, 2022
Merged

Add corner coordinate helper methods to Ellipse/Rectangle#21977
QuLogic merged 1 commit intomatplotlib:mainfrom
dstansby:patch-helpers

Conversation

@dstansby
Copy link
Copy Markdown
Member

PR Summary

This is pulled out of #21945 because it's a standalone feature, and I think it's worth the scrutiny of a separate PR.

PR Checklist

Tests and Styling

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (install flake8-docstrings and run flake8 --docstring-convention=all).

Documentation

  • New features are documented, with examples if plot related.
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).

@dstansby dstansby added this to the v3.6.0 milestone Dec 16, 2021
Copy link
Copy Markdown
Member

@ericpre ericpre left a comment

Choose a reason for hiding this comment

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

It would be good to add a test with rotation.

Comment thread lib/matplotlib/tests/test_patches.py Outdated
Comment thread lib/matplotlib/patches.py Outdated
Comment thread lib/matplotlib/patches.py Outdated
Comment thread lib/matplotlib/patches.py
Comment thread lib/matplotlib/patches.py Outdated
Comment thread lib/matplotlib/tests/test_patches.py
@dstansby dstansby force-pushed the patch-helpers branch 3 times, most recently from 09dd9aa to f155550 Compare December 17, 2021 13:05
@dstansby
Copy link
Copy Markdown
Member Author

Sorry for the messy PR... I've dropped edge_centers (I'll add them as private API in the widget PR), and should have resolved all the other comments.

Comment thread lib/matplotlib/patches.py Outdated
def get_corners(self):
"""
Return the corners of the ellipse bounding box, moving anti-clockwise
from the lower left.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is it really lower left? Can't angle be over 90?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, it's lower left in the de-rotated frame. I'm not sure what the best way to phrase this is - perhaps just "from the lower left before rotation is applied."?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Would it better and clear enough to use "anchor point" (xy), as this term is used in the Rectangle patch docstring?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I don't think that works for Ellipse though, since the "anchor point" is the center.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Indeed, it isn't sensible for the Ellipse patch - sorry I read too quickly!
Is it worth having a get_corners property as public API for the Ellipse patch? Maybe there could a private API _get_corners for both (Rectangle and Ellipse) and Rectangle patch could have the public get_corners as a convenience property?

@dstansby dstansby changed the title Add corner/edge coordinate helpers methods to Ellipse/Rectangle Add corner coordinate helper methods to Ellipse/Rectangle Dec 19, 2021
Copy link
Copy Markdown
Member

@ericpre ericpre left a comment

Choose a reason for hiding this comment

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

#21977 (comment) could be improved but this is already good.

Comment thread lib/matplotlib/patches.py Outdated
@QuLogic QuLogic merged commit 6a74631 into matplotlib:main Jan 5, 2022
@dstansby dstansby deleted the patch-helpers branch January 5, 2022 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants