八月
1
matplotlib教程:极坐标
import numpy as np
import matplotlib.pyplot as plt
r = np.arange(1, 6)
theta = [0, np.pi/2, np.pi, np.pi*3/2, np.pi*2]
fig = plt.figure()
# projection='polar',把轴定义为极坐标
ax = fig.add_subplot(111, projection='polar')
# 极坐标画图,参数为先角度后半径
ax.plot(theta, r, color='r', linewidth=3)
# 例2
r = np.ones(5) * 5
theta = [0, np.pi/2, np.pi, np.pi*3/2, np.pi*2]
ax.plot(theta, r, color='r', linewidth=3)
ax.grid(True)
fig.show()