Python:在雷达图中填充区域

Python:在雷达图中填充区域,python,matplotlib,Python,Matplotlib,我在这里画了一幅雷达图: 我期待着将多边形下的灰色区域填充为其他颜色。我找不到任何方法来做这件事 生成此雷达图的代码如下所示: import matplotlib.pyplot as plt from matplotlib.patches import Polygon fig, ax = plt.subplots(figsize=(20, 10)) ax.axis('equal') ## setting the axis so that we can draw circles

我在这里画了一幅雷达图:

我期待着将多边形下的灰色区域填充为其他颜色。我找不到任何方法来做这件事

生成此雷达图的代码如下所示:

import matplotlib.pyplot as plt
from matplotlib.patches import Polygon

fig, ax = plt.subplots(figsize=(20, 10))
ax.axis('equal')         ## setting the axis so that we can draw circles

ax.set(xlim=(-10, 23), ylim = (-15, 15))

# drawing the circles
circle_1 = plt.Circle((0, 0), 1.1, fc='none', ec='#D6D6D6', lw=28, zorder=3)
circle_2 = plt.Circle((0, 0), 2.57, fc='none', ec='#D6D6D6', lw=27, zorder=3)
circle_3 = plt.Circle((0, 0), 4.05, fc='none', ec='#D6D6D6', lw=27, zorder=3)
circle_4 = plt.Circle((0, 0), 5.5, fc='none', ec='#D6D6D6', lw=27, zorder=3)
circle_5 = plt.Circle((0, 0), 7.0, fc='none', ec='#D6D6D6', lw=27, zorder=3)

ax.add_artist(circle_1)
ax.add_artist(circle_2)
ax.add_artist(circle_3)
ax.add_artist(circle_4)
ax.add_artist(circle_5)


radar_1 = Polygon([[0, 6.45], [4.3, 4.3], [5.46, 0.02], [6.5, -3.55], [-0.04, -2.25], [-5.5, -3.5], [-6.55, 0.0], [-0.33, 4.7]],
                   fc='#246864', lw=1.2, zorder=2)
radar_2 = Polygon([[0, 6.45], [4.3, 4.3], [5.46, 0.02], [6.5, -3.55], [-0.04, -2.25], [-5.5, -3.5], [-6.55, 0.0], [-0.33, 4.7]],
                  fc='none', ec='#000000', zorder=3)

ax.add_artist(radar_1)
ax.add_artist(radar_2)


ax.axis('off')
plt.show()
使用
set\u clip\u path()
可以通过多边形剪裁圆:

导入matplotlib.pyplot作为plt
从matplotlib.patches导入多边形
图,ax=plt.子批次(图尺寸=(20,10))
ax.轴(“相等”)
ax.set(xlim=(-10,23),ylim=(-15,15))
顶点=[[0,6.45],[4.3,4.3],[5.46,0.02],[6.5,-3.55],-0.04,-2.25],-5.5,-3.5],-6.55,0.0],-0.33,4.7]]
雷达1=多边形(顶点,fc='#246864',lw=1.2,zorder=1)
雷达2=多边形(顶点,fc='none',ec='000000',zorder=4)
ax.添加_补丁(雷达_1)
ax.添加_补丁(雷达_2)
对于[1.1,2.57,4.05,5.5,7.0]中的rad:
圆1=plt.圆((0,0),rad,fc='none',ec='#d6d6',lw=27,zorder=2)
ax.添加补丁(圆圈1)
圆圈2=plt.Circle((0,0),rad,fc='none',ec='翠绿色',lw=27,zorder=3)
圆圈2.设置剪辑路径(雷达2)
ax.添加补丁(圆圈2)
ax.轴(“关闭”)
plt.紧_布局()