matplotlib 中的复杂极坐标图 [英] Complex polar plot in matplotlib
问题描述
我想创建一个类似于以下的极坐标图:
我找不到如何在不同角度范围内添加两个不同函数的示例.我不需要中间的径向偏移,但可能会很好.任何指针,已知示例都将是超级的!
它看起来就像其他用 matplotlib
绘图一样,即如果你想绘制两条曲线,你调用 plt.polar
多次.
这是一个例子:
将 numpy 导入为 np导入 matplotlib.pyplot 作为 pltblue_thetas = np.linspace(np.pi/3, 2*np.pi/3, 100)red_thetas = np.linspace(4*np.pi/3, 6*np.pi/3, 100)blue_rs = np.random.uniform(4, 6, len(blue_thetas))red_rs = np.random.uniform(3, 5, len(red_thetas))red_curve = plt.polar(red_thetas, red_rs, c='r', label="calculated")blue_curve = plt.polar(blue_thetas, blue_rs, c='b', label="measured")plt.legend(loc=10)plt.xticks(np.concatenate((red_thetas[::20], blue_thetas[::30])))plt.title("测试极坐标图像")plt.show()
来源:
I would like to create a polar plot similar the following:
I can't find an example of how to add two different functions over different ranges of angles. I don't need the radial offset in the middle, but might be nice. Any pointers, known examples would be super!
It appears to be just like other plotting with matplotlib
, i.e. if you want to plot two curves, you call plt.polar
multiple times.
Here is an example:
import numpy as np
import matplotlib.pyplot as plt
blue_thetas = np.linspace(np.pi/3, 2*np.pi/3, 100)
red_thetas = np.linspace(4*np.pi/3, 6*np.pi/3, 100)
blue_rs = np.random.uniform(4, 6, len(blue_thetas))
red_rs = np.random.uniform(3, 5, len(red_thetas))
red_curve = plt.polar(red_thetas, red_rs, c='r', label="calculated")
blue_curve = plt.polar(blue_thetas, blue_rs, c='b', label="measured")
plt.legend(loc=10)
plt.xticks(np.concatenate((red_thetas[::20], blue_thetas[::30])))
plt.title("test polar image")
plt.show()
source: https://matplotlib.org/3.1.1/gallery/misc/transoffset.html#sphx-glr-gallery-misc-transoffset-py
Another stackoverflow post that might be useful for you is this: floating radial axis
这篇关于matplotlib 中的复杂极坐标图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!