Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions lib/matplotlib/patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -2338,6 +2338,24 @@ def __call__(self, x0, y0, width, height, mutation_size):
x0, y0 = x0 - pad, y0 - pad
return Path.circle((x0 + width / 2, y0 + height / 2),
max(width, height) / 2)

@_register_style(_style_list)
class Ellipse:
"""A ellipse curve."""

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,width, height, mutation_size):

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.

Suggested change
def __call__(self,width, height, mutation_size):
def __call__(self, x0, y0, width, height, mutation_size):

x0 and y0 are the positions of the text.

You will need to adjust the size, taking pad in to account, for this to work. See the Circle style above.

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

return ellipse_path

@_register_style(_style_list)
class LArrow:
Expand Down