8000 Merge pull request #20027 from anntzer/axvspp · matplotlib/matplotlib@7a12f32 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7a12f32

Browse files
authored
Merge pull request #20027 from anntzer/axvspp
Fix axvspan for drawing slices on polar plots.
2 parents c06e870 + 77149ba commit 7a12f32

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
``axvspan`` now plots full wedges in polar plots
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
... rather than triangles.

lib/matplotlib/axes/_axes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -974,6 +974,7 @@ def axvspan(self, xmin, xmax, ymin=0, ymax=1, **kwargs):
974974
verts = [(xmin, ymin), (xmin, ymax), (xmax, ymax), (xmax, ymin)]
975975
p = mpatches.Polygon(verts, **kwargs)
976976
p.set_transform(self.get_xaxis_transform(which="grid"))
977+
p.get_path()._interpolation_steps = 100
977978
self.add_patch(p)
978979
self._request_autoscale_view(scaley=False)
979980
return p

lib/matplotlib/tests/test_polar.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,3 +373,9 @@ def test_default_thetalocator():
373373
ticklocs = np.degrees(ax.xaxis.get_majorticklocs()).tolist()
374374
assert pytest.approx(90) in ticklocs
375375
assert pytest.approx(100) not in ticklocs
376+
377+
378+
def test_axvspan():
379+
ax = plt.subplot(projection="polar")
380+
span = plt.axvspan(0, np.pi/4)
381+
assert span.get_path()._interpolation_steps > 1

0 commit comments

Comments
 (0)
0