10000 Correct theta values when drawing a non-circular ellipse · matplotlib/matplotlib@29470f9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 29470f9

Browse files
committed
Correct theta values when drawing a non-circular ellipse
1 parent c15694b commit 29470f9

File tree

5 files changed

+884
-9
lines changed

5 files changed

+884
-9
lines changed

lib/matplotlib/patches.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1554,7 +1554,18 @@ def __init__(self, xy, width, height, angle=0.0,
15541554
self.theta1 = theta1
15551555
self.theta2 = theta2
15561556

1557-
self._path = Path.arc(self.theta1, self.theta2)
1557+
# If the width and height of ellipse are not equal, take into account
1558+
# stretching when calculating angles to draw between
1559+
def theta_stretch(theta, scale):
1560+
theta = np.deg2rad(theta)
1561+
x = np.cos(theta)
1562+
y = np.sin(theta)
1563+
return np.rad2deg(np.arctan2(scale * y, x))
1564+
1565+
theta1 = theta_stretch(theta1, width / height)
1566+
theta2 = theta_stretch(theta2, width / height)
1567+
1568+
self._path = Path.arc(theta1, theta2)
15581569

15591570
@allow_rasterization
15601571
def draw(self, renderer):
Binary file not shown.
Loading

0 commit comments

Comments
 (0)
0