Python可視化神器pyecharts繪制?;鶊D
?;鶊D
桑基圖(Sankey diagram),即?;芰糠至鲌D,也叫?;芰科胶鈭D。它是一種特定類型的流程圖,圖中延伸的分支的寬度對應(yīng)數(shù)據(jù)流量的大小,通常應(yīng)用于? ?能源???、材料成分、? ?金融???等數(shù)據(jù)的可視化分析。因1898年Matthew Henry Phineas Riall Sankey繪制的“? ?蒸汽機(jī)??的能源效率圖”而聞名,此后便以其名字命名為“?;鶊D”。
?;鶊D最明顯的特征就是,始末端的分支寬度總和相等,即所有主支寬度的總和應(yīng)與所有分出去的分支寬度的總和相等,保持能量的平衡。
?;鶊D系列模板
第一個?;鶊D
from pyecharts import options as opts from pyecharts.charts import Sankey nodes = [ {"name": "category1"}, {"name": "category2"}, {"name": "category3"}, {"name": "category4"}, {"name": "category5"}, {"name": "category6"}, ] links = [ {"source": "category1", "target": "category2", "value": 10}, {"source": "category2", "target": "category3", "value": 15}, {"source": "category3", "target": "category4", "value": 20}, {"source": "category5", "target": "category6", "value": 25}, ] c = ( Sankey() .add( "sankey", nodes, links, linestyle_opt=opts.LineStyleOpts(opacity=0.2, curve=0.5, color="source"), label_opts=opts.LabelOpts(position="right"), ) .set_global_opts(title_opts=opts.TitleOpts(title="標(biāo)題")) .render("?;鶊D.html") )
復(fù)雜?;鶊D
from pyecharts import options as opts from pyecharts.charts import Sankey colors = [ "#67001f", "#b2182b", "#d6604d", "#f4a582", "#fddbc7", "#d1e5f0", "#92c5de", "#4393c3", "#2166ac", "#053061", ] nodes = [ {"name": "a"}, {"name": "b"}, {"name": "a1"}, {"name": "b1"}, {"name": "c"}, {"name": "e"}, ] links = [ {"source": "a", "target": "a1", "value": 5}, {"source": "e", "target": "b", "value": 3}, {"source": "a", "target": "b1", "value": 3}, {"source": "b1", "target": "a1", "value": 1}, {"source": "b1", "target": "c", "value": 2}, {"source": "b", "target": "c", "value": 1}, ] c = ( Sankey() .set_colors(colors) .add( "sankey", nodes=nodes, links=links, pos_bottom="10%", focus_node_adjacency="allEdges", orient="vertical", linestyle_opt=opts.LineStyleOpts(opacity=0.2, curve=0.5, color="source"), label_opts=opts.LabelOpts(position="top"), ) .set_global_opts( title_opts=opts.TitleOpts(title="標(biāo)題"), tooltip_opts=opts.TooltipOpts(trigger="item", trigger_on="mousemove"), ) .render("復(fù)雜桑基圖.html") )
這個?;鶊D的案例已經(jīng)可以完成你的可視化工作量了,其實一般研究桑基圖的還是相對于比較少。
到此這篇關(guān)于Python可視化神器pyecharts繪制桑基圖的文章就介紹到這了,更多相關(guān)pyecharts繪制?;鶊D內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
PaddleNLP ppdiffusers 自動生成兔了個兔海報
這篇文章主要為大家介紹了PaddleNLP ppdiffusers 自動生成兔了個兔海報示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-01-01Pandas數(shù)據(jù)分析固定時間點(diǎn)和時間差
這篇文章主要介紹了Pandas數(shù)據(jù)分析固定時間點(diǎn)和時間差,文章未日澳主題展開詳細(xì)的內(nèi)容介紹,具有一定的參考價值,需要的小伙伴可以參考一下2022-08-08Python中tkinter+MySQL實現(xiàn)增刪改查
這篇文章主要介紹了Python中tkinter+MySQL實現(xiàn)增刪改查,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2021-04-04python結(jié)合多線程爬取英雄聯(lián)盟皮膚(原理分析)
多線程是為了同步完成多項任務(wù),不是為了提高運(yùn)行效率,而是為了提高資源使用效率來提高系統(tǒng)的效率。這篇文章主要介紹了python爬取英雄聯(lián)盟皮膚結(jié)合多線程的方法,需要的朋友可以參考下2021-05-05Python學(xué)習(xí)小技巧之列表項的推導(dǎo)式與過濾操作
這篇文章主要給大家介紹了Python學(xué)習(xí)小技巧之列表項的推導(dǎo)式與過濾操作的相關(guān)資料,文中介紹的非常詳細(xì),對大家具有一定的參考學(xué)習(xí)價值,需要的朋友們下面來一起看看把。2017-05-05