椭圆的极坐标曲线

椭圆方程详细请参考: wiki
上代码:

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties
#设置中文字体
myfont = FontProperties(fname='C:/Windows/Fonts/msyh.ttc')

theta=np.arange(0,2*np.pi,0.02)

plt.subplot(111, polar=True, resolution=1)
# 这里的椭圆中心在原点, 短半轴3, 长半轴5
plt.plot(theta,3/np.sqrt(1-0.8**2*np.cos(theta+np.pi)**2),'b',lw=1,label=u'椭圆')
plt.plot(theta,9/(1-0.8**2*np.cos(theta+np.pi)**2),'--g',lw=2, label=u'椭圆平方')
x = 5*np.cos(theta); y = 3*np.sin(theta)
plt.plot(theta,(x**2+y**2),'r--',lw=2, label=u'椭圆偏光光强')
#plt.plot(np.arctan2(y,x),np.sqrt(x**2+y**2),'b.-',lw=1)    #椭圆
#plt.plot(np.arctan2(y,x),x**2+y**2,'b.-',lw=1)    #椭圆偏光光强
plt.rgrids(np.arange(5,30,5),angle=45)
#plt.thetagrids([0,45,90])
plt.legend(bbox_to_anchor=(0.02, 0.95), loc=2, prop=myfont)

plt.show()
椭圆的极坐标曲线_第1张图片

之所以椭圆偏光光强曲线与椭圆平方曲线没能重合, 是因为光强的方程采用的是直角坐标, 所以这里画在极坐标系中并不合适, 只是为了对比说明问题罢了!

你可能感兴趣的:(椭圆的极坐标曲线)