Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[ENH]: Ellipse annotation #24568

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

Closed
oscargus opened this issue Nov 30, 2022 · 2 comments Β· Fixed by #24596
Closed

[ENH]: Ellipse annotation #24568

oscargus opened this issue Nov 30, 2022 · 2 comments Β· Fixed by #24596
Labels
Good first issue Open a pull request against these issues if there are no active ones! New feature topic: annotation
Milestone

Comments

@oscargus
Copy link
Member

oscargus commented Nov 30, 2022

Problem

Currently there is only a circle annotation among the "round" annotations, which can be quite big for long texts.

Proposed solution

Add an ellipse annotation. Equations can be found here (second answer): https://stackoverflow.com/questions/433371/ellipse-bounding-a-rectangle

The code will be very similar to the circle annotation:

@_register_style(_style_list)
class Circle:
"""A circular box."""
def __init__(self, pad=0.3):
"""
Parameters
----------
pad : float, default: 0.3
The amount of padding around the original box.
"""
self.pad = pad
def __call__(self, x0, y0, width, height, mutation_size):
pad = mutation_size * self.pad
width, height = width + 2 * pad, height + 2 * pad
# boundary of the padded box
x0, y0 = x0 - pad, y0 - pad
return Path.circle((x0 + width / 2, y0 + height / 2),
max(width, height) / 2)

but with an ellipse rather than a circle.

There is also a bit of documentation to update, e.g., https://matplotlib.org/stable/tutorials/text/annotations.html

@oscargus oscargus added New feature Good first issue Open a pull request against these issues if there are no active ones! topic: annotation labels Nov 30, 2022
@ckcherry23
Copy link
Contributor

Hi, I am a new open-source contributor. Can I take this issue?

@oscargus
Copy link
Member Author

Please do! We do not assign issues though.

I think the main issue here is to get an ellipse path, but I believe it can be done from a circle path through a scale transform. Something like:

ellipse_path = Affine2D().scale(width, height).transform_path(Path.unit_circle())

(although there should also be locations etc).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Good first issue Open a pull request against these issues if there are no active ones! New feature topic: annotation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants