Python可視化神器pyecharts繪制雷達(dá)圖
雷達(dá)圖
雷達(dá)圖是以從同一點(diǎn)開(kāi)始的軸上表示的三個(gè)或更多個(gè)定量變量的二維圖表的形式顯示多變量數(shù)據(jù)的圖形方法。軸的相對(duì)位置和角度通常是無(wú)信息的。 雷達(dá)圖也稱(chēng)為網(wǎng)絡(luò)圖,蜘蛛圖,星圖,蜘蛛網(wǎng)圖,不規(guī)則多邊形,極坐標(biāo)圖或Kiviat圖。它相當(dāng)于? ?平行坐標(biāo)圖??,軸徑向排列。
平行坐標(biāo)圖:
平行坐標(biāo)圖是一種通常的可視化方法, 用于對(duì) 高維幾何 和 多元數(shù)據(jù) 的可視化。
為了表示在高維空間的一個(gè)點(diǎn)集,在N條平行的線的背景下,(一般這N條線都豎直且等距),一個(gè)在高維空間的點(diǎn)被表示為一條拐點(diǎn)在N條平行坐標(biāo)軸的折線,在第K個(gè)坐標(biāo)軸上的位置就表示這個(gè)點(diǎn)在第K個(gè)維的值。
平行坐標(biāo)圖是信息可視化的一種重要技術(shù)。為了克服傳統(tǒng)的笛卡爾直角坐標(biāo)系容易耗盡空間、 難以表達(dá)三維以上數(shù)據(jù)的問(wèn)題, 平行坐標(biāo)圖將高維數(shù)據(jù)的各個(gè)變量用一系列相互平行的坐標(biāo)軸表示, 變量值對(duì)應(yīng)軸上位置。為了反映變化趨勢(shì)和各個(gè)變量間相互關(guān)系,往往將描述不同變量的各點(diǎn)連接成折線。所以平行坐標(biāo)圖的實(shí)質(zhì)是將m維歐式空間的一個(gè)點(diǎn)Xi(xi1,xi2,...,xim) 映射到二維平面上的一條曲線。
平行坐標(biāo)圖的一個(gè)顯著優(yōu)點(diǎn)是其具有良好的數(shù)學(xué)基礎(chǔ),其射影幾何解釋和對(duì)偶特性使它很適合用于可視化數(shù)據(jù)分析。
雷達(dá)圖主要應(yīng)用于企業(yè)經(jīng)營(yíng)狀況—— href="https://baike.baidu.com/item/%E6%94%B6%E7%9B%8A" rel="nofollow" target="_blank"> 收益性、生產(chǎn)性、流動(dòng)性、安全性和成長(zhǎng)性的評(píng)價(jià)。上述指標(biāo)的分布組合在一起非常象雷達(dá)的形狀,因此而得名。
雷達(dá)圖模板系列
基礎(chǔ)雷達(dá)圖
import pyecharts.options as opts from pyecharts.charts import Radar v1 = [[4300, 10000, 28000, 35000, 50000, 19000]] v2 = [[5000, 14000, 28000, 31000, 42000, 21000]] ( Radar(init_opts=opts.InitOpts(width="1280px", height="720px", bg_color="#CCCCCC")) .add_schema( schema=[ opts.RadarIndicatorItem(name="銷(xiāo)售(sales)", max_=6500), opts.RadarIndicatorItem(name="管理(Administration)", max_=16000), opts.RadarIndicatorItem(name="信息技術(shù)(Information Technology)", max_=30000), opts.RadarIndicatorItem(name="客服(Customer Support)", max_=38000), opts.RadarIndicatorItem(name="研發(fā)(Development)", max_=52000), opts.RadarIndicatorItem(name="市場(chǎng)(Marketing)", max_=25000), ], splitarea_opt=opts.SplitAreaOpts( is_show=True, areastyle_opts=opts.AreaStyleOpts(opacity=1) ), textstyle_opts=opts.TextStyleOpts(color="#fff"), ) .add( series_name="預(yù)算分配(Allocated Budget)", data=v1, linestyle_opts=opts.LineStyleOpts(color="#CD0000"), ) .add( series_name="實(shí)際開(kāi)銷(xiāo)(Actual Spending)", data=v2, linestyle_opts=opts.LineStyleOpts(color="#5CACEE"), ) .set_series_opts(label_opts=opts.LabelOpts(is_show=False)) .set_global_opts( title_opts=opts.TitleOpts(title="基礎(chǔ)雷達(dá)圖"), legend_opts=opts.LegendOpts() ) .render("基礎(chǔ)雷達(dá)圖.html") )
單例雷達(dá)圖
from pyecharts import options as opts from pyecharts.charts import Radar v1 = [[4300, 10000, 28000, 35000, 50000, 19000]] v2 = [[5000, 14000, 28000, 31000, 42000, 21000]] c = ( Radar() .add_schema( schema=[ opts.RadarIndicatorItem(name="銷(xiāo)售", max_=6500), opts.RadarIndicatorItem(name="管理", max_=16000), opts.RadarIndicatorItem(name="信息技術(shù)", max_=30000), opts.RadarIndicatorItem(name="客服", max_=38000), opts.RadarIndicatorItem(name="研發(fā)", max_=52000), opts.RadarIndicatorItem(name="市場(chǎng)", max_=25000), ] ) .add("預(yù)算分配", v1) .add("實(shí)際開(kāi)銷(xiāo)", v2) .set_series_opts(label_opts=opts.LabelOpts(is_show=False)) .set_global_opts( legend_opts=opts.LegendOpts(selected_mode="single"), title_opts=opts.TitleOpts(title="標(biāo)題"), ) .render("一維雷達(dá)圖.html") )
空氣質(zhì)量模板
from pyecharts import options as opts from pyecharts.charts import Radar value_bj = [ [55, 9, 56, 0.46, 18, 6, 1], [25, 11, 21, 0.65, 34, 9, 2], [56, 7, 63, 0.3, 14, 5, 3], [33, 7, 29, 0.33, 16, 6, 4], [42, 24, 44, 0.76, 40, 16, 5], [82, 58, 90, 1.77, 68, 33, 6], [74, 49, 77, 1.46, 48, 27, 7], [78, 55, 80, 1.29, 59, 29, 8], [267, 216, 280, 4.8, 108, 64, 9], [185, 127, 216, 2.52, 61, 27, 10], [39, 19, 38, 0.57, 31, 15, 11], [41, 11, 40, 0.43, 21, 7, 12], ] value_sh = [ [91, 45, 125, 0.82, 34, 23, 1], [65, 27, 78, 0.86, 45, 29, 2], [83, 60, 84, 1.09, 73, 27, 3], [109, 81, 121, 1.28, 68, 51, 4], [106, 77, 114, 1.07, 55, 51, 5], [109, 81, 121, 1.28, 68, 51, 6], [106, 77, 114, 1.07, 55, 51, 7], [89, 65, 78, 0.86, 51, 26, 8], [53, 33, 47, 0.64, 50, 17, 9], [80, 55, 80, 1.01, 75, 24, 10], [117, 81, 124, 1.03, 45, 24, 11], [99, 71, 142, 1.1, 62, 42, 12], ] c_schema = [ {"name": "AQI", "max": 300, "min": 5}, {"name": "PM2.5", "max": 250, "min": 20}, {"name": "PM10", "max": 300, "min": 5}, {"name": "CO", "max": 5}, {"name": "NO2", "max": 200}, {"name": "SO2", "max": 100}, ] c = ( Radar() .add_schema(schema=c_schema, shape="circle") .add("北京", value_bj, color="#f9713c") .add("上海", value_sh, color="#b3e4a1") .set_series_opts(label_opts=opts.LabelOpts(is_show=False)) .set_global_opts(title_opts=opts.TitleOpts(title="空氣質(zhì)量")) .render("空氣質(zhì)量.html") )
顏色雷達(dá)圖
線條顏色可以配置:
from pyecharts import options as opts from pyecharts.charts import Radar data = [{"value": [4, -4, 2, 3, 0, 1], "name": "預(yù)算分配"}] c_schema = [ {"name": "銷(xiāo)售", "max": 4, "min": -4}, {"name": "管理", "max": 4, "min": -4}, {"name": "技術(shù)", "max": 4, "min": -4}, {"name": "客服", "max": 4, "min": -4}, {"name": "研發(fā)", "max": 4, "min": -4}, {"name": "市場(chǎng)", "max": 4, "min": -4}, ] c = ( Radar() .set_colors(["#4587E7"]) .add_schema( schema=c_schema, shape="circle", center=["50%", "50%"], radius="80%", angleaxis_opts=opts.AngleAxisOpts( min_=0, max_=360, is_clockwise=False, interval=5, axistick_opts=opts.AxisTickOpts(is_show=False), axislabel_opts=opts.LabelOpts(is_show=False), axisline_opts=opts.AxisLineOpts(is_show=False), splitline_opts=opts.SplitLineOpts(is_show=False), ), radiusaxis_opts=opts.RadiusAxisOpts( min_=-4, max_=4, interval=2, splitarea_opts=opts.SplitAreaOpts( is_show=True, areastyle_opts=opts.AreaStyleOpts(opacity=1) ), ), polar_opts=opts.PolarOpts(), splitarea_opt=opts.SplitAreaOpts(is_show=False), splitline_opt=opts.SplitLineOpts(is_show=False), ) .add( series_name="預(yù)算", data=data, areastyle_opts=opts.AreaStyleOpts(opacity=0.2), linestyle_opts=opts.LineStyleOpts(width=2), ) .render("顏色雷達(dá)圖.html") )
到此這篇關(guān)于Python可視化神器pyecharts繪制雷達(dá)圖的文章就介紹到這了,更多相關(guān)Python繪制雷達(dá)圖內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Python專(zhuān)用方法與迭代機(jī)制實(shí)例分析
這篇文章主要介紹了Python專(zhuān)用方法與迭代機(jī)制,包括類(lèi)的私有方法、專(zhuān)有方法、模塊私有對(duì)象、迭代__iter__()方法的對(duì)象等,需要的朋友可以參考下2014-09-09python操作csv格式文件之csv.DictReader()方法
這篇文章主要介紹了python操作csv格式文件之csv.DictReader()方法,文章圍繞主題展開(kāi)詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值,感興趣的小伙伴可以參考一下2022-06-06Python?matplotlib繪制散點(diǎn)圖配置(萬(wàn)能模板案例)
這篇文章主要介紹了Python?matplotlib繪制散點(diǎn)圖配置(萬(wàn)能模板案例),散點(diǎn)圖是指在??回歸分析???中,數(shù)據(jù)點(diǎn)在直角坐標(biāo)系平面上的?分布圖???,散點(diǎn)圖表示因變量隨??自變量???而?變化???的大致趨勢(shì),據(jù)此可以選擇合適的函數(shù)??對(duì)數(shù)???據(jù)點(diǎn)進(jìn)行?擬合2022-07-07python實(shí)現(xiàn)數(shù)據(jù)導(dǎo)出到excel的示例--普通格式
今天小編就為大家分享一篇python實(shí)現(xiàn)數(shù)據(jù)導(dǎo)出到excel的示例--普通格式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2018-05-05Numpy中的數(shù)組搜索中np.where方法詳細(xì)介紹
這篇文章主要介紹了Numpy中的數(shù)組搜索中np.where方法詳細(xì)介紹,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2021-01-01python遍歷迭代器自動(dòng)鏈?zhǔn)教幚頂?shù)據(jù)的實(shí)例代碼
迭代器也是用來(lái)遍歷對(duì)象成員的,下面這篇文章主要給大家介紹了關(guān)于python遍歷迭代器自動(dòng)鏈?zhǔn)教幚頂?shù)據(jù)的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),需要的朋友可以參考下2022-01-01使用Python正則表達(dá)式操作文本數(shù)據(jù)的方法
這篇文章主要介紹了使用Python正則表達(dá)式操作文本數(shù)據(jù)的方法,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2019-05-05特征臉(Eigenface)理論基礎(chǔ)之PCA主成分分析法
這篇文章主要為大家詳細(xì)介紹了特征臉理論基礎(chǔ)之PCA主成分分析法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-03-03