-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Adding ellipse_arrow.py example and closes #25477 #25779
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
Adding ellipse_arrow.py example and closes #25477 #25779
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.
Unfortunately, |
FYI, the "Closes #25477" needs to go in the body of the PR description to automatically link, not the title. I've gone ahead and added it for this one |
…end point position of the ellipse minor axis rotated by the transform.Affine2D method.
I changed the demo in the last commit to use paches.Ellipse and a marker rotated by transform.Affine2D. One example almost looks a little sad. Do you want me to add anything more? |
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.
Examples should focus on their main aspect. Less code makes them more comprehensible.
Not sure we need two ellipses. You could also just write
Note: To reverse the orientation arrow, switch the marker type from
>
to<
.
and only show one ellipse, which would remove again half of the code an the need for legend and labels.
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.
Also, please add your new functions to the type stubs
matplotlib/lib/matplotlib/patches.pyi
Line 234 in e7fd79f
class Ellipse(Patch): |
How do I solve the failed checks? @matplotlib/developers |
The failures in the OSX build pipeline are unrelated to this PR and can be ignored. |
Co-authored-by: Tim Hoffmann <[email protected]>
@timhoffm Thanks for approving! How is responsible to do the Release Note actions metioned by GitHub actions? Or is there something else for me to do? |
If you've got the time, please write release notes about the new functions-otherwise I put on the new feature label so we can find this at release time and hopefully catch that the notes are missing. They can be really simple-something like https://github.com/matplotlib/matplotlib/blob/main/doc/users/next_whats_new/get_suptitle.rst
|
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 the distinction between "vertex" and "co-vertex" is unclear here...
By the source (wiki article) listed, I believe that a "vertex" should be on the line defined by the foci, and a "co-vertex" should be on the perpendicular bisector of the foci.
Here, we define the ellipse by its bounding box, rather than by its foci.
If it is defined with height > width, then I think the definition would be reversed from if height < width, but the computation does not account for that.
Additionally, "left" vs "right" doesn't necessarily make sense (They could be aligned along the vertical axis, and even if they aren't then it's not really adding anything to the definition)
Perhaps this could be implemented as a single function that returns all four points, without necessarily specifying order?
Finally, should probably have a .. versionadded:: 3.8
directive in the docstring if we are trying to do that.
I think it could be implemented as def get_corners(self):
"""
Return the corners of the ellipse bounding box.
The bounding box orientation is moving anti-clockwise from the
lower left corner defined before rotation.
"""
return self.get_patch_transform().transform(
[(-1, -1), (1, -1), (1, 1), (-1, 1)])
def get_vertices(self):
"""
Return the vertices and covertices of the ellipse.
...Maybe look at order that would be desired
"""
return self.get_patch_transform().transform(
[(0, 1), (1, 0), (0, -1), (-1, 0)]) |
I agree by defining width and height it is not clear which is the minor or major axis. But I understand the definiton of vertex and co-vertex as the end points of such axes not related to the foci!? Would it be clear if depending on the length of the major and minor axes the vertex are returned? |
|
…ajor and minor axis depending on the length between the coordinates of points
@ksunden I believe it's important to be able to distinguish between the vertices and covertices easily. A single function makes this hard (even if it had a guarantee on the order). I therefore believe that the two separate functions are the right API choice. |
I mean, the foci definition is exactly the same. From the wiki article, section "Definition as a locus of points":
I do stand by that computing using the transform as is done for the def get_vertices(self):
if self.width < self.height:
ret = self.get_patch_transform().transform([(0, 1), (0, -1)])
else:
ret = self.get_patch_transform().transform([(1, 0), (-1, 0)])
return [tuple(x) for x in ret]
def get_co_vertices(self):
if self.width < self.height:
ret = self.get_patch_transform().transform([(1, 0), (-1, 0)])
else:
ret = self.get_patch_transform().transform([(0, 1), (0, -1)])
return [tuple(x) for x in ret] I will also point out that the Ellipse patch already has a |
…transform() for coordinate calculations.
Ok, I understand. |
The naming similarity is not so nice but it's the best we can do: Changing the existing API My approval still stands. |
Implementation has been adjusted, and api concerns approved by Tim
PR Summary
In this PR I want to add a Demo file. This Demo shows how an ellipse is plotted with an additional arrow showing the orientation of rotation.
Closes #25477
pre-commit.ci autofix
PR Checklist
Linked Issue
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/
next_whats_new/README.rst
ornext_api_changes/README.rst