Polar coordinate drawing-square, triangle

Polar coordinate drawing

// An highlighted block
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')
#(theta:角度,r:绘图点的位置,linewidth:线条宽度)
ax.plot(theta,r,color='r',linewidth=3)
ax.grid(True)
plt.show()

Insert picture description here

Square drawing

// An highlighted block
import numpy as np
import matplotlib.pyplot as plt
r=np.arange(5)
#将r只取5
r.fill(5)
#0,90,180,270,360
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()

Insert picture description here

Triangle drawing

// An highlighted block
import numpy as np
import matplotlib.pyplot as plt
r=np.arange(4)
r.fill(4)
#-30,90,210,330
theta=[-np.pi/6,np.pi/2,7*np.pi/6,11*np.pi/6]
ax=plt.subplot(111,projection='polar')
ax.plot(theta,r,color='r',linewidth=3)
ax.grid(True)
plt.show()

Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_42567027/article/details/107340893