溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

Python怎么使用pyecharts繪制?;鶊D

發(fā)布時(shí)間:2022-07-07 09:57:17 來(lái)源:億速云 閱讀:263 作者:iii 欄目:開發(fā)技術(shù)

本篇內(nèi)容主要講解“Python怎么使用pyecharts繪制?;鶊D”,感興趣的朋友不妨來(lái)看看。本文介紹的方法操作簡(jiǎn)單快捷,實(shí)用性強(qiáng)。下面就讓小編來(lái)帶大家學(xué)習(xí)“Python怎么使用pyecharts繪制?;鶊D”吧!

?;鶊D

?;鶊D(Sankey diagram),即?;芰糠至鲌D,也叫?;芰科胶鈭D。它是一種特定類型的流程圖,圖中延伸的分支的寬度對(duì)應(yīng)數(shù)據(jù)流量的大小,通常應(yīng)用于 能源、材料成分、 金融等數(shù)據(jù)的可視化分析。因1898年Matthew Henry Phineas Riall Sankey繪制的“ 蒸汽機(jī)的能源效率圖”而聞名,此后便以其名字命名為“?;鶊D”。

?;鶊D最明顯的特征就是,始末端的分支寬度總和相等,即所有主支寬度的總和應(yīng)與所有分出去的分支寬度的總和相等,保持能量的平衡。

?;鶊D系列模板

第一個(gè)桑基圖

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")
)

Python怎么使用pyecharts繪制?;鶊D

復(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ù)雜?;鶊D.html")
)

Python怎么使用pyecharts繪制?;鶊D

到此,相信大家對(duì)“Python怎么使用pyecharts繪制?;鶊D”有了更深的了解,不妨來(lái)實(shí)際操作一番吧!這里是億速云網(wǎng)站,更多相關(guān)內(nèi)容可以進(jìn)入相關(guān)頻道進(jìn)行查詢,關(guān)注我們,繼續(xù)學(xué)習(xí)!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI