电脑
python
matplotlib模块
绘制极坐标图像:import matplotlib.pyplot as pltimport numpy as npa = plt.subplot(121, projection='polar')b = plt.subplot(122, projection='polar')t=np.linspace(0,2*np.pi,30) #采样a.plot(t,np.sin(3*t),'.',c='g',)b.plot(t,np.sin(3*t),'-',c='r',)plt.show()
增加采样数:t=np.linspace(0,2*np.pi,60)
一般的,采样数越大,曲线看起来越光滑:import matplotlib.pyplot as pltimport numpy as npfor n in range(30,101,5): a = plt.subplot(121, projection='polar') b = plt.subplot(122, projection='polar') t=np.linspace(0,2*np.pi,n) a.plot(t,np.sin(3*t),'.',c='g',) b.plot(t,np.sin(3*t),'-',c='r',) plt.savefig(str(n)+'.png',dpi=100)plt.show()
第二幅图的线条变细:b.plot(t,np.sin(3*t),'-',c='r',lw=0.5)
用虚线绘制图像:b.plot(t,np.sin(3*t),'--',c='r',lw=1)
用虚线和点交替绘制图像:b.plot(t,np.sin(3*t),'-.',c='r',lw=1)
用像素点画图:b.plot(t,np.sin(3*t),',',c='b',)
用三角形代替点:b.plot(t,np.sin(3*t),'^',c='b',)
用三尖形代替点:b.plot(t,np.sin(3*t),'1',c='b',)
用正方形代替点:b.plot(t,np.sin(3*t),'s',c='b',)
用平行四边形代替点:b.plot(t,np.sin(3*t),'d',c='b',)
用短线代替点:b.plot(t,np.sin(3*t),'_',c='b',)