1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
"""
==========
Polar plot
==========
Demo of a line plot on a polar axis.
"""
import matplotlib.pyplot as plt
import numpy as np
r = np.arange(0, 2, 0.01)
theta = 2 * np.pi * r
fig, ax = plt.subplots(subplot_kw={'projection': 'polar'})
ax.plot(theta, r)
ax.set_rmax(2)
ax.set_rticks([0.5, 1, 1.5, 2]) # Less 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')
plt.show()
# %%
#
# .. admonition:: References
#
# The use of the following functions, methods, classes and modules is shown
# in this example:
#
# - `matplotlib.axes.Axes.plot` / `matplotlib.pyplot.plot`
# - `matplotlib.projections.polar`
# - `matplotlib.projections.polar.PolarAxes`
# - `matplotlib.projections.polar.PolarAxes.set_rticks`
# - `matplotlib.projections.polar.PolarAxes.set_rmax`
# - `matplotlib.projections.polar.PolarAxes.set_rlabel_position`
#
# .. tags::
#
# plot-type: polar
# level: beginner
|