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

Backport PR #30180 on branch v3.10.x (DOC: expand polar example)#30189

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Changes fromall 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
26 changes: 24 additions & 2 deletionsgalleries/examples/pie_and_polar_charts/polar_demo.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,21 +4,41 @@
==========
Demo of a line plot on a polar axis.
The second plot shows the same data, but with the radial axis starting at r=1
and the angular axis starting at 0 degrees and ending at 225 degrees. Setting
the origin of the radial axis to 0 allows the radial ticks to be placed at the
same location as the first plot.
"""
importmatplotlib.pyplotasplt
importnumpyasnp

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

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

ax.set_title("A line plot on a polar axis",va='bottom')

ax=axs[1]
ax.plot(theta,r)
ax.set_rmax(2)
ax.set_rmin(1)# Change the radial axis to only go from 1 to 2
ax.set_rorigin(0)# Set the origin of the radial axis to 0
ax.set_thetamin(0)
ax.set_thetamax(225)
ax.set_rticks([1,1.5,2])# Fewer radial ticks
ax.set_rlabel_position(-22.5)# Move radial labels away from plotted line

ax.grid(True)
ax.set_title("Same plot, but with reduced axis limits",va='bottom')
plt.show()

# %%
Expand All@@ -32,6 +52,8 @@
# - `matplotlib.projections.polar`
# - `matplotlib.projections.polar.PolarAxes`
# - `matplotlib.projections.polar.PolarAxes.set_rticks`
# - `matplotlib.projections.polar.PolarAxes.set_rmin`
# - `matplotlib.projections.polar.PolarAxes.set_rorigin`
# - `matplotlib.projections.polar.PolarAxes.set_rmax`
# - `matplotlib.projections.polar.PolarAxes.set_rlabel_position`
#
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp