Thursday, September 29, 2016

Python: Matplotlib: Polar Plot Example

Noteworthy:

ax.set_rmax()


Command:

$ cat Downloads/polar_demo.py


Result:

"""
Demo of a line plot on a polar axis.
"""
import numpy as np
import matplotlib.pyplot as plt

plt.style.use('dark_background')
r = np.arange(0, 3.0, 0.01)
theta = 2 * np.pi * r

ax = plt.subplot(111, projection='polar')
ax.plot(theta, r, color='r', linewidth=3)
ax.set_rmax(2.0)
ax.grid(True)

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


Graphical output:

pyplot_polar_demo.png