首页 > 解决方案 > matplotlib 中的复杂极坐标图

问题描述

我想创建一个类似于以下的极坐标图:

阴谋

我找不到如何在不同角度范围内添加两个不同功能的示例。我不需要中间的径向偏移,但可能会很好。任何指针,已知的例子都很棒!

标签: pythonmatplotlibvisualizationpolar-coordinates

解决方案


它看起来就像其他绘图一样matplotlib,即如果你想绘制两条曲线,你会调用plt.polar多次。

这是一个例子:

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()

来源:https ://matplotlib.org/3.1.1/gallery/misc/transoffset.html#sphx-glr-gallery-misc-transoffset-py

另一个可能对您有用的stackoverflow帖子是:浮动径向轴

极坐标图示例


推荐阅读