天天看點

【Python學習】matplotlib雷達圖繪制

plot_data:

【Python學習】matplotlib雷達圖繪制

labels = [‘ZL’, ‘ZR’, ‘ZF’, ‘ZM’, ‘ZC’] #标簽

k = 5 #資料個數

color = [‘b’, ‘g’, ‘r’, ‘c’, ‘y’] #指定顔色

angles = np.linspace(0, 2*np.pi, k, endpoint=False)

plot_data = np.concatenate((plot_data, plot_data[:,[0]]), axis=1) # 閉合

angles = np.concatenate((angles, [angles[0]])) # 閉合

fig = plt.figure()

ax = fig.add_subplot(111, polar=True) #polar參數!!

for i in range(len(plot_data)):

ax.plot(angles, plot_data[i], ‘o-’, color = color[i], label = u’客戶群’+str(i), linewidth=2)# 畫線

ax.set_rgrids(np.arange(-1, 2.5, 0.5), fontproperties=“SimHei”)

ax.set_thetagrids(angles * 180/np.pi, labels, fontproperties=“SimHei”)

plt.legend(loc = 4)

plt.title(‘different kind’)

plt.show()

【Python學習】matplotlib雷達圖繪制