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

Skip to content

Commit 8063e15

Browse files
dhomeierdstansby
andcommitted
Add edge midpoint helper methods
Co-authored-by: David Stansby <[email protected]>
1 parent 29f3a5c commit 8063e15

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

lib/matplotlib/patches.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -877,6 +877,14 @@ def get_corners(self):
877877
return self.get_patch_transform().transform(
878878
[(0, 0), (1, 0), (1, 1), (0, 1)])
879879

880+
def _get_edge_midpoints(self):
881+
"""
882+
Return the edge midpoints of the rectangle, moving anti-clockwise from
883+
the centre of the left-hand edge.
884+
"""
885+
return self.get_patch_transform().transform(
886+
[(0, 0.5), (0.5, 0), (1, 0.5), (0.5, 1)])
887+
880888
def get_center(self):
881889
"""Return the centre of the rectangle."""
882890
return self.get_patch_transform().transform((0.5, 0.5))
@@ -1794,6 +1802,14 @@ def get_co_vertices(self):
17941802
ret = self.get_patch_transform().transform([(0, 1), (0, -1)])
17951803
return [tuple(x) for x in ret]
17961804

1805+
def _get_edge_midpoints(self):
1806+
"""
1807+
Return the edge midpoints of the ellipse, moving anti-clockwise from
1808+
the centre of the left-hand edge.
1809+
"""
1810+
return self.get_patch_transform().transform(
1811+
[(0, 0.5), (0.5, 0), (1, 0.5), (0.5, 1)])
1812+
17971813

17981814
class Annulus(Patch):
17991815
"""

0 commit comments

Comments
 (0)