python - 在极坐标的两条线之间填充

标签 python matplotlib plot fill polar-coordinates

我正在尝试填充两端未闭合的两条线之间的空间。我不能用 plt.polar 得到 plt.fill_between,有什么想法吗?这是我用来绘制线条的代码:

import matplotlib.pyplot as plt
import numpy as np 

inner_offset = 0.05
r = np.arange(inner_offset,1. + inner_offset,1./720.)
theta = np.arange(0.,2.,1./360.)*np.pi 

plt.polar(theta/2.,r) #first part of spiral
plt.polar((theta/2.)+(np.pi/3.),r)

plt.show()

最佳答案

由于您的半径 ("y") 相同,您可以使用 plt.fill_betweenx():

import matplotlib.pyplot as plt
import numpy as np

plt.figure()
inner_offset = 0.05
r = np.arange(inner_offset,1. + inner_offset,1./720.)
theta = np.arange(0.,2.,1./360.)*np.pi

c1 = plt.polar(theta/2.,r, color='b')[0]
x1 = c1.get_xdata()
y1 = c1.get_ydata()
c2 = plt.polar((theta/2.)+(np.pi/3.),r, color='y')[0]
x2 = c2.get_xdata()
y2 = c2.get_ydata()

plt.fill_betweenx(y1, x1, x2, color='g')
plt.show()

给予:

enter image description here

关于python - 在极坐标的两条线之间填充,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23664646/

相关文章:

plot - 为什么 gnuplot 时间数据图中的常规 x 轴和 x2 轴之间存在差异?

python - 如何修复此 python 错误?溢出错误 : cannot convert float infinity to integer

python - 属性错误 : member not defined python

python - 在 Python 图表中设置箱线图之间的空间使用 Seaborn 生成嵌套箱线图?

python - 基于动态值更新 Matplotlib 中的轴

python - %matplotlib 笔记本显示空白直方图

r - 按行索引(数据的原始顺序)而不是按字母顺序设置 ggplot 中 x 或 y 的顺序

python - Python 中替代开关的性能差异

尝试使用 list.insert 时出现 Python 索引错误

r - 使用带有频率计数的表中的 R 绘制饼图和直方图