使用matplotlib fill_between填充两条极坐标曲线

时间:2014-12-01 13:48:14

标签: python matplotlib

我有一种感觉,我会在这一个上砸我的额头,但我正在尝试填充两个极地函数r = 4 sin(2θ)和{{1}的共同内部 }}。看来我正好与我想要的相反。有什么想法吗?

r = 2

Polar Plot

1 个答案:

答案 0 :(得分:5)

也许计算r和r2的最小值,然后在0和最小值之间填充:

import numpy as np
import matplotlib.pyplot as plt

theta = np.arange(0, 2, 1./180)*np.pi
r = abs(4*np.sin(2*theta))
r2 = 2 + 0*theta
r3 = np.minimum(r, r2)
plt.polar(theta, r, lw=3)
plt.polar(theta, r2, lw=3)
plt.fill_between(theta, 0, r3, alpha=0.2)
plt.show()

enter image description here

相关问题