我想用Matplotlib的图形绘制带有弧线的雷达图。
所以,我试图用我的代码绘制这张图
spider_df = pd.DataFrame(dict(
A=np.random.uniform(0, 1, size=7),
B=np.random.uniform(0, 1, size=7),
C=np.random.uniform(0, 1, size=7),
D=np.random.uniform(0, 1, size=7)
)).T
spider_df.columns = ['A1', "A2", "A3", "A4", "A5", "A6", "A7"]
theta = np.arange(0, 2*np.pi, 2*np.pi/(7))
labels = spider_df.columns
stats_A = spider_df.iloc[0,:].values
stats_B = spider_df.iloc[1,:].values
stats_C = spider_df.iloc[2,:].values
stats_D = spider_df.iloc[3,:].values
angles=np.linspace(0, 2*np.pi, len(labels), endpoint=False)
fig=plt.figure(figsize=(8,8))
ax = fig.add_subplot(111, polar=True)
ax.set_thetagrids(angles * 180/np.pi, labels)
ax.bar(theta, stats_A, width= 0.7, label = "2015",alpha = 0.25, color = 'green')
ax.bar(theta, stats_B, width = 0.7, label = "2016", alpha = 0.7, fill = None,edgecolor = 'blue',
linewidth =2)
ax.bar(theta, stats_C, width = 0.7, label = "2017", alpha = 0.7, fill = None,edgecolor = 'purple',
linestyle = "-.", linewidth = 2)
ax.bar(theta, stats_D, width = 0.7, label = "2018", alpha = 0.7, fill=None, edgecolor = 'red',
linestyle = ":", linewidth = 2)
plt.ylim(0,1)
ax.set_title('Comparing Dataset')
ax.grid(True)
ax.yaxis.grid(False)
# ax.xaxis.grid(False)
plt.legend(loc = (0.75,1))
plt.savefig('polarchart_stack.png')
我的代码返回此输出图
我想知道如何仅在不具有圆弧半径的情况下为圆弧绘制图形,以及如何在雷达图图形中绘制与我的参考图一样的轴之间的阴影区域。