pyecharts Graph關係圖示例

import webbrowser

from pyecharts import options as opts
from pyecharts.charts import Graph

nodes = [
    opts.GraphNode(name="結點1", symbol_size=10),
    opts.GraphNode(name="結點2", symbol_size=20,symbol="diamond"),
    opts.GraphNode(name="結點3", symbol_size=30,symbol="roundRect"),
    opts.GraphNode(name="結點4", symbol_size=40),
    opts.GraphNode(name="結點5", symbol_size=200, label_opts = opts.LabelOpts(font_size=50, position="inside",color="yellow")),
]
links = [
    opts.GraphLink(source="結點1", target="結點2",symbol_size=30,linestyle_opts=opts.LineStyleOpts(color="green")),
    opts.GraphLink(source="結點2", target="結點3"),
    opts.GraphLink(source="結點3", target="結點4"),
    opts.GraphLink(source="結點4", target="結點5"),
    opts.GraphLink(source="結點5", target="結點1"),
]
c = (
    Graph()
    .add("", nodes, links, repulsion=5000,edge_symbol= ['circle', 'arrow'])
    .set_global_opts(title_opts=opts.TitleOpts(title="關係圖示例"))
    .render("e:/tests/關係圖系列.html")
)

webbrowser.open("e:/tests/關係圖系列.html")

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章