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

Skip to content

Commit 38055bc

Browse files
dhomeierdstansby
andcommitted
Add edge midpoint helper methods
Co-authored-by: David Stansby <[email protected]>
1 parent a04e35f commit 38055bc

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
@@ -844,6 +844,14 @@ def get_corners(self):
844844
return self.get_patch_transform().transform(
845845
[(0, 0), (1, 0), (1, 1), (0, 1)])
846846

847+
def _get_edge_midpoints(self):
848+
"""
849+
Return the edge midpoints of the rectangle, moving anti-clockwise from
850+
the centre of the left-hand edge.
851+
"""
852+
return self.get_patch_transform().transform(
853+
[(0, 0.5), (0.5, 0), (1, 0.5), (0.5, 1)])
854+
847855
def get_center(self):
848856
"""Return the centre of the rectangle."""
849857
return self.get_patch_transform().transform((0.5, 0.5))
@@ -1761,6 +1769,14 @@ def get_co_vertices(self):
17611769
ret = self.get_patch_transform().transform([(0, 1), (0, -1)])
17621770
return [tuple(x) for x in ret]
17631771

1772+
def _get_edge_midpoints(self):
1773+
"""
1774+
Return the edge midpoints of the ellipse, moving anti-clockwise from
1775+
the centre of the left-hand edge.
1776+
"""
1777+
return self.get_patch_transform().transform(
1778+
[(0, 0.5), (0.5, 0), (1, 0.5), (0.5, 1)])
1779+
17641780

17651781
class Annulus(Patch):
17661782
"""

0 commit comments

Comments
 (0)