-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
ENH: Add ellipse class for annotation box styles #24596
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
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.
Thank you for opening your first PR into Matplotlib!
If you have not heard from us in a while, please feel free to ping @matplotlib/developers
or anyone who has commented on the PR. Most of our reviewers are volunteers and sometimes things fall through the cracks.
You can also join us on gitter for real-time discussion.
For details on testing, writing docs, and our review process, please see the developer guide
We strive to be a welcoming and open project. Please follow our Code of Conduct.
Looks promising! If you can add info here: matplotlib/tutorials/text/annotations.py Lines 202 to 203 in 7f7dfc9
of the new shape. Here one can see that it is working: I'll add some comments in the code as well. There is a failing test at the moment. It should just be to update the test image so that includes the ellipse as well. |
Oh, and I think that it may be worthwhile to highlight this addition through a What's new note. If you want to, write some short text and a minor example showing how it can be used. See examples is https://github.com/matplotlib/matplotlib/tree/main/doc/users/next_whats_new |
Co-authored-by: Oscar Gustafsson <[email protected]>
Co-authored-by: Oscar Gustafsson <[email protected]>
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.
modulo fixing the docs build.
Looks good, thank you @ckcherry23 ! We are just waiting for a second review. |
Agree that it looks good! Let me just check the equations (now it seems like the padding is scaled, but I cannot really get my head around it as it looks like the padding is scaled down by sqrt(2), but in the image it looks like the padding has increased if anything). |
OK, there is a slightly different behavior of the Here is what happens with circle, this and what possibly may be a preferred interpretation of As seen, for circle, the leftmost, the padding is on the radius of the circle. For this PR, the middle, the padding is on the bounding box and then the ellipse is touching the padded box. One may think that the padding could be as in the rightmost figure, but I do not think that it is a problem as one probably will try to figure out a good padding anyway. (I also realized that with I'll approve this as the code is good as such, but not merge it to get a second opinion on the behavior. Thanks for your effort! |
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.
Good code, but would like to have a second opinion on the behavior.
|
@oscargus how are you defining the angle on the pad in the above? Is it going through the center of the text bounding box? |
That was my idea, yes, as that seems to be a quite natural way to define it, closest distance to the bounding box (although any angle will have that...). But I guess that there are more options, like 45 degrees. Considering that the Circle pad is a bit different compared to the others, I am not sure if it actually matters that Ellipse is a bit "off" as well. I guess my main idea was that the pad should be visually similar for the same value. |
Another reason is that the equations become a bit easier for that case, compared to e.g. 45 degrees, although the computational burden is not that huge anyway. Edit: actually, they are straightforward for 45 degrees as well. |
On a bit more consideration I think that there are a bunch of reasonable definitions of pad and there is really only one degree of freedom here. It is not clear to me one definition of pad is more obviously right or more natural nor is it clear that the definition of I'm in favor of merging this as-is and accept the apparent inconsistency because the inconsistency is inevitable. |
Thanks @ckcherry23 ! Hope to see you around! |
PR Summary
Create a new 'Ellipse' annotation box style that is modelled by the 'Circle' class
Fixes #24568
PR Checklist
Documentation and Tests
pytest
passes)Release Notes
.. versionadded::
directive in the docstring and documented indoc/users/next_whats_new/
.. versionchanged::
directive in the docstring and documented indoc/api/next_api_changes/
[N/A]next_whats_new/README.rst
ornext_api_changes/README.rst