利用极坐标创建图形
import numpy as np
import matplotlib.pyplot as plt
r = np.arange(1, 6)#取到中心长度
theta = [0, np.pi/2, np.pi, 3*np.pi/2, 2*np.pi]#取点
ax = plt.subplot(111, projection='polar')
ax.plot(theta, r, color='r', linewidth=3)
ax.grid(True)
plt.show()
r = np.empty(5)
r.fill(5)#一个正方形
theta = [0, np.pi/2, np.pi, 3*np.pi/2, 2*np.pi]
ax = plt.subplot(111, projection='polar')
ax.plot(theta, r, color='r', linewidth=3)
ax.grid(True)
plt.show()
r = np.empty(9)
r.fill(9)#八边形
pi_two = 2*np.pi
theta = [0, pi_two/8, pi_two/4, 3*pi_two/8, pi_two/2, 5*pi_two/8, 6*pi_two/8, 7*pi_two/8, pi_two]
ax = plt.subplot(111, projection='polar')
ax.plot(theta, r, color='r', linewidth=3)
ax.grid(True)
plt.show()