Python實(shí)例15:霍蘭德人格分析雷達(dá)圖
雷達(dá)圖是多特性直觀展示的重要方式访忿;
霍蘭德認(rèn)為:人格興趣與職業(yè)之間應(yīng)有一種內(nèi)在的對(duì)應(yīng)關(guān)系瞧栗;
人格分類:研究型、藝術(shù)型海铆、社會(huì)型迹恐、企業(yè)型、傳統(tǒng)型卧斟、現(xiàn)實(shí)型殴边;
職業(yè):工程師、實(shí)驗(yàn)員珍语、藝術(shù)家锤岸、推銷員、記事員板乙、社會(huì)工作者是偷;
需求:雷達(dá)圖方式驗(yàn)證霍蘭德人格分析;
輸入:各職業(yè)人群結(jié)合興趣的調(diào)研數(shù)據(jù)募逞;
輸出:雷達(dá)圖蛋铆;
通用雷達(dá)圖繪制:matplotlib庫;專業(yè)的多維數(shù)據(jù)表示:numpy庫凡辱;
9.2.1 實(shí)例展示
#HollandRadarDraw.py
import numpy as np #引入第三方庫
import matplotlib.pyplot as plt
import matplotlib
#數(shù)據(jù)
matplotlib.rcParams['font.family'] = 'SimHei'
radar_labels = np.array(['研究型(I)','藝術(shù)型(A)','社會(huì)型(S)','企業(yè)型(E)','常規(guī)型(C)','現(xiàn)實(shí)型(R)'])
data = np.array([[0.40, 0.32, 0.35, 0.30, 0.30, 0.88],
[0.85, 0.35, 0.30, 0.40, 0.40, 0.30],
[0.43, 0.89, 0.30, 0.28, 0.22, 0.30],
[0.30, 0.25, 0.48, 0.85, 0.45, 0.40],
[0.20, 0.38, 0.87, 0.45, 0.32, 0.28],
[0.34, 0.31, 0.38, 0.40, 0.92, 0.28]]) #數(shù)據(jù)值
data_labels = ('藝術(shù)家','實(shí)驗(yàn)員','工程師','推銷員','社會(huì)工作者','記事員')
#雷達(dá)圖繪制
angles= np.linspace(0, 2 * np.pi, 6, endpoint=False)
data = np.concatenate((data, [data[0]]))
angles = np.concatenate((angles, [angles[0]]))
fig = plt.figure(facecolor="white")
plt.subplot(111, polar=True)
plt.plot(angles, data, 'o-', linewidth = 1, alpha = 0.2)
plt.fill(angles, data, alpha = 0.25)
plt.thetagrids(angles*180/np.pi, radar_labels)
#plt.thetagrids(angles*180/np.pi, radar_labels, frac = 1.2)
#輸出
plt.figtext(0.52, 0.95, '霍蘭德人格分析', ha = 'center', size = 20)
legend = plt.legend(data_labels, loc = (0.94, 0.80), labelspacing = 0.1)
plt.setp(legend.get_texts(), fontsize = 'large')
plt.grid(True)
plt.savefig('holland_radar.jpg')
plt.show()
在這里插入圖片描述
點(diǎn)贊戒职,關(guān)注,收藏??透乾,?洪燥,??點(diǎn)贊,關(guān)注乳乌,收藏??捧韵,?,??點(diǎn)贊汉操,關(guān)注再来,收藏??,?磷瘤,??
????????????????????????????????????????????????????????????????
????????????????????????????????????????????????????????????????
在這里插入圖片描述