所以我正在绘制雷达图,我需要在图表的每个点的末尾添加值。有办法吗?下面列出了主要的代码和 df 区域。
"""PLOT GRAPH 1"""
categories=list(df)[0:]
N = len(categories)
categories=list(df)[0:]
N = len(categories)
values=df.iloc[1].values.flatten().tolist()
values += values[:1]
for_tick=df.iloc[0].values.flatten().tolist()
for_tick += for_tick[:1]
angles = [n / float(N) * 2 * pi for n in range(N)]
angles += angles[:1]
f, ax = plt.subplots(1,1,figsize=(8,6))
ax = plt.subplot(111, polar=True)
plt.xticks(angles[:-1], wrapped_labels , size=10)
ax.set_rlabel_position(0)
plt.yticks([0,25,50,75,100], color="grey", size=5)
plt.ylim(0,100)
plt.title('Suppliers hit in the test out of all supliers (' +number_of_suppliers+') (in %)')
ax.plot(angles, values, color='#ffe600', linewidth=1, linestyle='solid')
ax.fill(angles, values, color='#ffe600', alpha=0.3)
plt.savefig(r'C:\Radar\firmy.png',dpi=100)
plt.show()
答案 0 :(得分:0)
所以我设法找到了一种更手动的方法,因为只有五个值需要标记,关于如何做,添加了这行代码。如果我找到更直观和自动的方式,我会更新你:)
ax.annotate(labels[0], xy=(angles[0],values[0]), textcoords='data',size=5,ha="center", va="center")
ax.annotate(labels[1], xy=(angles[1],values[1]), textcoords='data',size=5,ha="center", va="center")
ax.annotate(labels[2], xy=(angles[2],values[2]), textcoords='data',size=5,ha="center", va="center")
ax.annotate(labels[3], xy=(angles[3],values[3]), textcoords='data',size=5,ha="center", va="center")
ax.annotate(labels[4], xy=(angles[4],values[4]), textcoords='data',size=5,ha="center", va="center")