Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 77149ba

Browse filesBrowse files
committed
Fix axvspan for drawing slices on polar plots.
There's already special-casing for polar plots in bar() (using the same `_interpolation_steps = 100`); it seems reasonable to use the same approach for axvspan (e.g. `polar(); axvspan(0, pi/4)`). It seems like making axhspan work (basically drawing full rings) is less easy, but there's an easy enough workaround (`polar(); bar(0, bottom=1, height=1, width=2*pi)`) as the "x" (theta) extent is actually known in that case.
1 parent 5c8cf78 commit 77149ba
Copy full SHA for 77149ba

File tree

Expand file treeCollapse file tree

3 files changed

+10
-0
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+10
-0
lines changed
+3Lines 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

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_axes.py
+1Lines 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

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_polar.py
+6Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.