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

Skip to content

[ENH]: Ellipse annotation #24568

Closed
Closed
@oscargus

Description

@oscargus

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions