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

Skip to content

Commit 4d09108

Browse files
authored
Merge pull request #9661 from QuLogic/fix-arcs
Fix arcs with very large width/height.
2 parents c465993 + 0f69fd9 commit 4d09108

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

lib/matplotlib/patches.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1737,7 +1737,7 @@ def iter_circle_intersect_on_line_seg(x0, y0, x1, y1):
17371737
path_original = self._path
17381738
for theta in thetas:
17391739
if inside:
1740-
Path.arc(last_theta, theta, 8)
1740+
self._path = Path.arc(last_theta, theta, 8)
17411741
Patch.draw(self, renderer)
17421742
inside = False
17431743
else:
Loading

lib/matplotlib/tests/test_axes.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,22 +1206,32 @@ def test_arc_angles():
12061206
w = 2
12071207
h = 1
12081208
centre = (0.2, 0.5)
1209+
scale = 2
12091210

12101211
fig, axs = plt.subplots(3, 3)
12111212
for i, ax in enumerate(axs.flat):
12121213
theta2 = i * 360 / 9
12131214
theta1 = theta2 - 45
1215+
12141216
ax.add_patch(patches.Ellipse(centre, w, h, alpha=0.3))
12151217
ax.add_patch(patches.Arc(centre, w, h, theta1=theta1, theta2=theta2))
12161218
# Straight lines intersecting start and end of arc
1217-
ax.plot([2 * np.cos(np.deg2rad(theta1)) + centre[0],
1219+
ax.plot([scale * np.cos(np.deg2rad(theta1)) + centre[0],
12181220
centre[0],
1219-
2 * np.cos(np.deg2rad(theta2)) + centre[0]],
1220-
[2 * np.sin(np.deg2rad(theta1)) + centre[1],
1221+
scale * np.cos(np.deg2rad(theta2)) + centre[0]],
1222+
[scale * np.sin(np.deg2rad(theta1)) + centre[1],
12211223
centre[1],
1222-
2 * np.sin(np.deg2rad(theta2)) + centre[1]])
1223-
ax.set_xlim(-2, 2)
1224-
ax.set_ylim(-2, 2)
1224+
scale * np.sin(np.deg2rad(theta2)) + centre[1]])
1225+
1226+
ax.set_xlim(-scale, scale)
1227+
ax.set_ylim(-scale, scale)
1228+
1229+
# This looks the same, but it triggers a different code path when it
1230+
# gets large enough.
1231+
w *= 10
1232+
h *= 10
1233+
centre = (centre[0] * 10, centre[1] * 10)
1234+
scale *= 10
12251235

12261236

12271237
@image_comparison(baseline_images=['arc_ellipse'],

0 commit comments

Comments
 (0)