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

Skip to content

Commit 3e2e31e

Browse files
authored
Merge pull request #8539 from Tuan333/tuan
Fix rectangular patches to be properly transformed on polar axes
2 parents 8149536 + 8dae4e1 commit 3e2e31e

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

lib/matplotlib/axes/_base.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1856,6 +1856,8 @@ def add_patch(self, p):
18561856
if p.get_clip_path() is None:
18571857
p.set_clip_path(self.patch)
18581858
self._update_patch_limits(p)
1859+
if self.name != 'rectilinear':
1860+
p.get_path()._interpolation_steps = max(p.get_path()._interpolation_steps, 100)
18591861
self.patches.append(p)
18601862
p._remove_method = lambda h: self.patches.remove(h)
18611863
return p

lib/matplotlib/tests/test_patches.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,3 +337,17 @@ def test_multi_color_hatch():
337337
with mstyle.context({'hatch.color': 'C{}'.format(i)}):
338338
r = Rectangle((i-.8/2, 5), .8, 1, hatch='//', fc='none')
339339
ax.add_patch(r)
340+
341+
342+
@image_comparison(baseline_images=['polar_proj'], extensions=['png'])
343+
def test_adding_rectangle_patch_with_polar_projection():
344+
fig = plt.figure()
345+
ax = fig.add_subplot(111, projection='polar')
346+
347+
# add quadrant as example
348+
ax.add_patch(
349+
mpatches.Rectangle(
350+
(0, 1), width=np.pi * 0.5, height=0.5
351+
)
352+
)
353+
ax.set_rmax(2)

0 commit comments

Comments
 (0)