Matplotlib:在极坐标图上使用非线性比例

时间:2020-07-04 18:36:18

标签: python matplotlib

我想绘制一个测得的天线辐射方向图。目前,我正在使用以下脚本:

#!/usr/bin/env python3 -u
# vim: set ai et ts=4 sw=4:

from math import pi
import matplotlib.pyplot as plt
import csv

xs = []
ys = []
with open('raw-data.csv', newline = '') as f:
    for row in csv.reader(f, delimiter = ',', quotechar = '"'):
        xs += [ 2*pi*float(row[0])/360 ]
        ys += [ float(row[1]) ]

max_y = max(ys)
ys = [ y - max_y for y in ys ]

dpi = 80
fig = plt.figure(dpi = dpi, figsize = (512 / dpi, 384 / dpi) )

ax = plt.subplot(111, projection='polar')
ax.set_theta_offset(2*pi*90/360)
ax.plot(xs, ys, linestyle = 'solid', linewidth=3)
ax.set_rmax(0)
ax.set_rticks([-6*i for i in range(0,7)])
ax.set_yticklabels([''] + [str(-6*i) for i in range(1,7)])
ax.set_rlabel_position(0)
ax.set_thetagrids(range(0, 360, 15))
ax.set_theta_direction(-1)
ax.grid(True)

fig.savefig('linear.png')

这是raw-data.csv:

0,-31.4
10,-31.9
20,-32
30,-32.4
40,-38.1
50,-41.1
60,-44.5
70,-59
80,-73
90,-67.3
100,-70.5
110,-62.1
120,-58.2
130,-55.7
140,-55.6
150,-54.7
160,-50.3
170,-43.7
180,-40.8
190,-41.2
200,-43.2
210,-45.9
220,-49.7
230,-53.8
240,-57.3
250,-60.6
260,-65.2
270,-61.6
280,-61.1
290,-60.8
300,-52.9
310,-46.2
320,-39.7
330,-35.1
340,-33.3
350,-31.9
360,-31.4

我对结果几乎满意

enter image description here

但是我希望比例会有所不同,例如ARRL常用的比例。这是一个示例:

enter image description here

请注意,比例尺是非线性的。这是《 ARRL天线手册》对此的描述:

ARRL使用的修改后的对数网格具有一个同心网格线系统,该网格线的对数间隔是信号电压值的0.89倍。在此网格中,与主瓣相比低30到40 dB的次瓣是可以区分的。在VHF和UHF工作中,此类波瓣令人担忧。绘制点之间的间隔为0 dB和 –3 dB显着大于–20和–23 dB之间的间隔,而后者又显着大于–50和–53 dB之间的间隔。 例如,0到–3 dB覆盖的刻度距离大约是图表半径的1/10。准确地说,下一个3 dB增量(至–6 dB)的音阶距离要短一些,为第一个的89%。下一个3 dB增量(至–9 dB)的刻度距离再次为秒的89%。标尺的构造应使进度在图表中心以–100 dB结尾。 因此,间隔的周期性通常对应于这种天线性能变化的相对重要性。该出版物中的天线方向图在类似于图A-(C)所示的修改对数网格上绘制。

我不需要ARRL使用的确切方法,但是看起来相似的东西会很好。我尝试了不同的方法,但没有成功。例如,当我尝试使用ax.set_rscale('function',...时,会得到如下图像:

enter image description here

不胜感激。

0 个答案:

没有答案
相关问题