做天线辐射函数的极坐标图的问题

问题描述 投票:0回答:1

我正在尝试绘制这个辐射模式图

以下等式:

我可以部分制作:

%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 度角线。

我也想绘制方位角 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,)

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

python matplotlib polar-coordinates
1个回答
0
投票

考虑使用 2 个 numpy 向量 pattern = [patternH,patternV] 例如 .MSI 天线数据或函数点。

pattern = [patternH,patternV]
NameFig = "Plot.jpg"
Titolo = "First Picture"

M_PI_O_180 = .01745329251994329576
r = np.arange(0, 360, 1)
theta = r*M_PI_O_180
fig, axs = plt.subplots(1,2,figsize=(11, 6),subplot_kw={"projection" : "polar"})
fig.suptitle('Modello '+Titolo, fontsize=12)

ax = axs[0]
ax.plot(theta,pattern[0],linewidth= 2.5)
ax.set_rmax(0)
ax.set_theta_direction(-1)
ax.set_thetagrids([0,30, 60,90,120,150,180,210,240,270,300,330])
ax.set_rticks([-3, -10,-20],labels= ["-3dB", "-10dB","-20dB"])
ax.set_rlabel_position(270)
ax.grid(True,which="minor",linestyle= ":")
ax.grid(True,which="major",linewidth= 1.2)
ax.minorticks_on()
ax.set_title("Diagramma Orizzontale", {"va":"bottom"})

axs[1].plot(theta,pattern[1],linewidth= 2.5)
axs[1].set_rmax(0)
axs[1].set_theta_direction(-1)
axs[1].set_thetagrids([0,30, 60,90,120,150,180,210,240,270,300,330])
axs[1].set_rticks([-3, -10,-20,-30,-40],labels= ["-3dB", "-10dB","-20dB","-30dB","-40dB"])
axs[1].set_rlabel_position(270)
axs[1].grid(True,which="minor",linestyle= ":")
axs[1].grid(True,which="major",linewidth= 1.2)
axs[1].minorticks_on()
axs[1].set_title("Diagramma Verticale", {"va":"bottom"})
plt.savefig(NameFig)

© www.soinside.com 2019 - 2024. All rights reserved.