av一区二区在线观看_亚洲男人的天堂网站_日韩亚洲视频_在线成人免费_欧美日韩精品免费观看视频_久草视

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

Python繪制雷達(dá)圖時(shí)遇到的坑的解決

瀏覽:3日期:2022-06-22 09:29:52

ValueError: The number of FixedLocator locations (9), usually from a call to set_ticks, does not match the number of ticklabels (8).

運(yùn)行書(shū)中例題時(shí)發(fā)現(xiàn)了這個(gè)錯(cuò)誤,原代碼如上:

import numpy as npimport matplotlib.pyplot as pltimport matplotlibmatplotlib.rcParams[’font.family’]=’simhei’# 某學(xué)生的課程與成績(jī)courses = np.array([’C++’,’Python’,’高數(shù)’,’大學(xué)英語(yǔ)’,’軟件工程’, ’組成原理’,’數(shù)字圖像處理’,’計(jì)算機(jī)圖形學(xué)’])scores=np.array([80,95,78,85,45,65,80,60])datalength = len(scores) #數(shù)據(jù)長(zhǎng)度# angles數(shù)組把圓周等分為dataLength份angles = np.linspace(0, #數(shù)組第一個(gè)數(shù)據(jù) 2*np.pi, #數(shù)組最后一個(gè)暑假 datalength, #數(shù)組中的數(shù)據(jù)量 endpoint=False) #不包含終點(diǎn)scores = np.concatenate((scores,[scores[0]]))angles = np.concatenate((angles,[angles[0]]))# 繪制雷達(dá)圖print(angles)print(’=’*20)print(scores)plt.polar(angles, scores, ’rv--’, linewidth=2)# 設(shè)置角度網(wǎng)絡(luò)標(biāo)簽plt.thetagrids(angles*180/np.pi,courses)# 填充雷達(dá)圖內(nèi)部plt.fill(angles,scores,facecolor=’r’,alpha=0.6)plt.show()

Python繪制雷達(dá)圖時(shí)遇到的坑的解決

自己搜查資料后,了解到,只對(duì)socres,和angles做閉合還是不夠

需要再對(duì)courses進(jìn)行閉合

courses = np.concatenate((courses,[courses[0]]))

Python繪制雷達(dá)圖時(shí)遇到的坑的解決

此時(shí)就能正確運(yùn)行出來(lái)。

這里在附上霍蘭德人格分析代碼:

import numpy as npimport matplotlib.pyplot as pltimport matplotlibmatplotlib.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]])data_labels =(’藝術(shù)家’,’實(shí)驗(yàn)員’,’工程師’,’推銷員’,’社會(huì)工作者’,’記事員’)angles = np.linspace(0, 2*np.pi, 6, endpoint=False)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.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()

Python繪制雷達(dá)圖時(shí)遇到的坑的解決

到此這篇關(guān)于Python繪制雷達(dá)圖時(shí)遇到的坑的解決的文章就介紹到這了,更多相關(guān)Python繪制雷達(dá)圖內(nèi)容請(qǐng)搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!

標(biāo)簽: Python 編程
相關(guān)文章:
主站蜘蛛池模板: 国产精品成人一区二区 | 日韩欧美国产综合 | 欧美精品久久久久 | 国产在线视频一区二区 | 91精品一区| 四虎最新视频 | 亚洲 欧美 综合 | 久久久久久久久久毛片 | 一区二区中文 | 国内精品在线视频 | 亚洲91精品 | 国产高清久久久 | 一区二区三区四区不卡视频 | 久久久久久久久久久久久9999 | 成人精品鲁一区一区二区 | 男人的天堂久久 | 精品av| 欧美一区二区三区久久精品 | 成年人免费网站 | 久久综合九九 | 日韩在线视频一区 | 日韩欧美国产精品一区二区 | 在线观看免费福利 | 免费在线观看一区二区三区 | 久久精品色欧美aⅴ一区二区 | 久久久久国色av免费观看性色 | 一本一道久久a久久精品蜜桃 | 亚洲导航深夜福利涩涩屋 | 亚洲在线| 国产精华一区 | 久久综合影院 | 久久久久久久久久久福利观看 | 中文在线一区二区 | 波多野结衣中文字幕一区二区三区 | 成人h视频在线观看 | 欧美日韩a | 四虎在线观看 | 日干夜操 | 日韩欧美视频在线 | 久久婷婷麻豆国产91天堂 | 99国产精品久久久久老师 |