Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitb7f8468

Browse files
authored
Merge pull request#30189 from meeseeksmachine/auto-backport-of-pr-30180-on-v3.10.x
Backport PR#30180 on branch v3.10.x (DOC: expand polar example)
2 parentsd739282 +dbee871 commitb7f8468

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

‎galleries/examples/pie_and_polar_charts/polar_demo.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,41 @@
44
==========
55
66
Demo of a line plot on a polar axis.
7+
8+
The second plot shows the same data, but with the radial axis starting at r=1
9+
and the angular axis starting at 0 degrees and ending at 225 degrees. Setting
10+
the origin of the radial axis to 0 allows the radial ticks to be placed at the
11+
same location as the first plot.
712
"""
813
importmatplotlib.pyplotasplt
914
importnumpyasnp
1015

1116
r=np.arange(0,2,0.01)
1217
theta=2*np.pi*r
1318

14-
fig,ax=plt.subplots(subplot_kw={'projection':'polar'})
19+
fig,axs=plt.subplots(2,1,figsize=(5,8),subplot_kw={'projection':'polar'},
20+
layout='constrained')
21+
ax=axs[0]
1522
ax.plot(theta,r)
1623
ax.set_rmax(2)
17-
ax.set_rticks([0.5,1,1.5,2])#Less radial ticks
24+
ax.set_rticks([0.5,1,1.5,2])#Fewer radial ticks
1825
ax.set_rlabel_position(-22.5)# Move radial labels away from plotted line
1926
ax.grid(True)
2027

2128
ax.set_title("A line plot on a polar axis",va='bottom')
29+
30+
ax=axs[1]
31+
ax.plot(theta,r)
32+
ax.set_rmax(2)
33+
ax.set_rmin(1)# Change the radial axis to only go from 1 to 2
34+
ax.set_rorigin(0)# Set the origin of the radial axis to 0
35+
ax.set_thetamin(0)
36+
ax.set_thetamax(225)
37+
ax.set_rticks([1,1.5,2])# Fewer radial ticks
38+
ax.set_rlabel_position(-22.5)# Move radial labels away from plotted line
39+
40+
ax.grid(True)
41+
ax.set_title("Same plot, but with reduced axis limits",va='bottom')
2242
plt.show()
2343

2444
# %%
@@ -32,6 +52,8 @@
3252
# - `matplotlib.projections.polar`
3353
# - `matplotlib.projections.polar.PolarAxes`
3454
# - `matplotlib.projections.polar.PolarAxes.set_rticks`
55+
# - `matplotlib.projections.polar.PolarAxes.set_rmin`
56+
# - `matplotlib.projections.polar.PolarAxes.set_rorigin`
3557
# - `matplotlib.projections.polar.PolarAxes.set_rmax`
3658
# - `matplotlib.projections.polar.PolarAxes.set_rlabel_position`
3759
#

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp