Skip to content

Fix rectangular patches to be properly transformed on polar axes #8539

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from Apr 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/matplotlib/axes/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1856,6 +1856,8 @@ def add_patch(self, p):
if p.get_clip_path() is None:
p.set_clip_path(self.patch)
self._update_patch_limits(p)
if self.name != 'rectilinear':
p.get_path()._interpolation_steps = max(p.get_path()._interpolation_steps, 100)
self.patches.append(p)
p._remove_method = lambda h: self.patches.remove(h)
return p
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions lib/matplotlib/tests/test_patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,3 +337,17 @@ def test_multi_color_hatch():
with mstyle.context({'hatch.color': 'C{}'.format(i)}):
r = Rectangle((i-.8/2, 5), .8, 1, hatch='//', fc='none')
ax.add_patch(r)


@image_comparison(baseline_images=['polar_proj'], extensions=['png'])
def test_adding_rectangle_patch_with_polar_projection():
fig = plt.figure()
ax = fig.add_subplot(111, projection='polar')

# add quadrant as example
ax.add_patch(
mpatches.Rectangle(
(0, 1), width=np.pi * 0.5, height=0.5
)
)
ax.set_rmax(2)