我正在尝试填充两端未关闭的两条线之间的空间。我不能得到plt.fill_between与plt.polar,任何想法?这是我用来绘制线条的代码:
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()
答案 0 :(得分:5)
由于您的半径("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()
,并提供: