Python可視化神器pyecharts繪制雷達圖
雷達圖
雷達圖是以從同一點開始的軸上表示的三個或更多個定量變量的二維圖表的形式顯示多變量數(shù)據(jù)的圖形方法。軸的相對位置和角度通常是無信息的。 雷達圖也稱為網(wǎng)絡(luò)圖,蜘蛛圖,星圖,蜘蛛網(wǎng)圖,不規(guī)則多邊形,極坐標圖或Kiviat圖。它相當(dāng)于? ?平行坐標圖??,軸徑向排列。
平行坐標圖:
平行坐標圖是一種通常的可視化方法, 用于對 高維幾何 和 多元數(shù)據(jù) 的可視化。
為了表示在高維空間的一個點集,在N條平行的線的背景下,(一般這N條線都豎直且等距),一個在高維空間的點被表示為一條拐點在N條平行坐標軸的折線,在第K個坐標軸上的位置就表示這個點在第K個維的值。
平行坐標圖是信息可視化的一種重要技術(shù)。為了克服傳統(tǒng)的笛卡爾直角坐標系容易耗盡空間、 難以表達三維以上數(shù)據(jù)的問題, 平行坐標圖將高維數(shù)據(jù)的各個變量用一系列相互平行的坐標軸表示, 變量值對應(yīng)軸上位置。為了反映變化趨勢和各個變量間相互關(guān)系,往往將描述不同變量的各點連接成折線。所以平行坐標圖的實質(zhì)是將m維歐式空間的一個點Xi(xi1,xi2,...,xim) 映射到二維平面上的一條曲線。
平行坐標圖的一個顯著優(yōu)點是其具有良好的數(shù)學(xué)基礎(chǔ),其射影幾何解釋和對偶特性使它很適合用于可視化數(shù)據(jù)分析。
雷達圖主要應(yīng)用于企業(yè)經(jīng)營狀況—— href="https://baike.baidu.com/item/%E6%94%B6%E7%9B%8A" rel="nofollow" target="_blank"> 收益性、生產(chǎn)性、流動性、安全性和成長性的評價。上述指標的分布組合在一起非常象雷達的形狀,因此而得名。
雷達圖模板系列
基礎(chǔ)雷達圖
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="銷售(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="市場(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="實際開銷(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ǔ)雷達圖"), legend_opts=opts.LegendOpts() ) .render("基礎(chǔ)雷達圖.html") )
單例雷達圖
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="銷售", 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="市場", max_=25000), ] ) .add("預(yù)算分配", v1) .add("實際開銷", 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="標題"), ) .render("一維雷達圖.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") )
顏色雷達圖
線條顏色可以配置:
from pyecharts import options as opts from pyecharts.charts import Radar data = [{"value": [4, -4, 2, 3, 0, 1], "name": "預(yù)算分配"}] c_schema = [ {"name": "銷售", "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": "市場", "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("顏色雷達圖.html") )
到此這篇關(guān)于Python可視化神器pyecharts繪制雷達圖的文章就介紹到這了,更多相關(guān)Python繪制雷達圖內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
python操作csv格式文件之csv.DictReader()方法
這篇文章主要介紹了python操作csv格式文件之csv.DictReader()方法,文章圍繞主題展開詳細的內(nèi)容介紹,具有一定的參考價值,感興趣的小伙伴可以參考一下2022-06-06Python?matplotlib繪制散點圖配置(萬能模板案例)
這篇文章主要介紹了Python?matplotlib繪制散點圖配置(萬能模板案例),散點圖是指在??回歸分析???中,數(shù)據(jù)點在直角坐標系平面上的?分布圖???,散點圖表示因變量隨??自變量???而?變化???的大致趨勢,據(jù)此可以選擇合適的函數(shù)??對數(shù)???據(jù)點進行?擬合2022-07-07python實現(xiàn)數(shù)據(jù)導(dǎo)出到excel的示例--普通格式
今天小編就為大家分享一篇python實現(xiàn)數(shù)據(jù)導(dǎo)出到excel的示例--普通格式,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-05-05Numpy中的數(shù)組搜索中np.where方法詳細介紹
這篇文章主要介紹了Numpy中的數(shù)組搜索中np.where方法詳細介紹,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2021-01-01python遍歷迭代器自動鏈式處理數(shù)據(jù)的實例代碼
迭代器也是用來遍歷對象成員的,下面這篇文章主要給大家介紹了關(guān)于python遍歷迭代器自動鏈式處理數(shù)據(jù)的相關(guān)資料,文中通過示例代碼介紹的非常詳細,需要的朋友可以參考下2022-01-01使用Python正則表達式操作文本數(shù)據(jù)的方法
這篇文章主要介紹了使用Python正則表達式操作文本數(shù)據(jù)的方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2019-05-05特征臉(Eigenface)理論基礎(chǔ)之PCA主成分分析法
這篇文章主要為大家詳細介紹了特征臉理論基礎(chǔ)之PCA主成分分析法,具有一定的參考價值,感興趣的小伙伴們可以參考一下2018-03-03