【问题标题】:Polar plots in pythonpython中的极坐标图
【发布时间】:2022-01-14 14:27:43
【问题描述】:

我正在尝试在 python 中绘制天线模式。我在 csv 文件中有测量的 theta 与半径读数。但是,当我尝试以下代码时

import numpy  as np
import matplotlib.pyplot as plt

gain_on = np.loadtxt('patterne.txt')


#------------------------------------------------------------------------


theta = gain_on[:, 0]
r = gain_on[:, 3]

fig1 = plt.figure()
ax1 = fig1.add_axes([0.1,0.1,0.8,0.8],polar=True)
ax1.set_rlim(-50,0)
#ax1.set_yticks(np.arange(-2,2,0.5))
ax1.plot(theta,r)
plt.show()

我得到这个输出 python polar plot

预期的情节是 expected plot 如何在 python 中获得预期的情节?

【问题讨论】:

  • 你的文件patterne.txt有什么内容?
  • 也许您希望theta = np.radians(theta) 将度数转换为弧度?
  • patterne.txt 文件的角度(以度为单位)与喇叭天线处的接收功率的关系。

标签: python numpy matplotlib


【解决方案1】:

将 theta 的单位从度更改为弧度:

theta = numpy.deg2rad(gain_on[:,0])

在 Matplotlib 极坐标图的示例中,它们总是使用弧度表示的角度。例如https://matplotlib.org/stable/gallery/pie_and_polar_charts/polar_demo.html

【讨论】:

    猜你喜欢
    • 2018-09-12
    • 2017-05-18
    • 1970-01-01
    • 1970-01-01
    • 2014-04-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多