在做天线辐射函数的极坐标图时遇到问题

时间:2019-10-29 16:57:20

标签: python matplotlib polar-coordinates

我正在尝试绘制此辐射方向图

enter image description here

以下等式:

enter image description here

我可以做一部分:

%matplotlib inline
import matplotlib.ticker
import matplotlib.pyplot as plt
plt.style.use('seaborn-white')
import numpy as np
import pylab as pl

def gain_dip(theta, phi):
    return 1.641*(np.cos(np.pi/2*np.cos(theta))/np.sin(theta))**2

theta = np.arange(-np.pi, np.pi,0.01)
# plot
ax = plt.subplot(111, polar=True)
# set zero west
ax.set_theta_zero_location('W')
ax.set_theta_direction('clockwise')
# let set an azimuth for example, pi
plt.plot(theta, gain_dip(theta, np.pi))

绘制仰角(theta),与示例的仰角相似。但是,它有一条不应成180度角的线。

enter image description here

我也想绘制方位角phi,但是当我尝试绘制时会出现错误:

phi = np.arange(-np.pi, np.pi,0.01)
ax = plt.subplot(111, polar=True)
# set zero west
ax.set_theta_zero_location('W')
ax.set_theta_direction('clockwise')
plt.plot(phi, gain_dip(np.pi/2, phi))

ValueError: x and y must have same first dimension, but have shapes (629,) and (1,)

而且,可以像在第一个图中一样绘制两个角度吗?

0 个答案:

没有答案