pyecharts Graph图表类型

阅读 47

2023-08-02

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

nodes = [
    {"name": "节点1", "symbolSize": 30},
    {"name": "节点2", "symbolSize": 20},
    {"name": "节点3", "symbolSize": 15},
    {"name": "节点4", "symbolSize": 25},
    {"name": "节点5", "symbolSize": 18},
    {"name": "节点6", "symbolSize": 22},
    {"name": "节点7", "symbolSize": 16},
    {"name": "节点8", "symbolSize": 28},
]

links = [
    {"source": "节点1", "target": "节点2"},
    {"source": "节点1", "target": "节点3"},
    {"source": "节点1", "target": "节点4"},
    {"source": "节点1", "target": "节点5"},
    {"source": "节点2", "target": "节点6"},
    {"source": "节点2", "target": "节点7"},
    {"source": "节点4", "target": "节点8"},
]

graph = (
    Graph()
    .add("", nodes, links, repulsion=8000, layout="force", label_opts=opts.LabelOpts())
    .set_global_opts(title_opts=opts.TitleOpts(title="Graph示例"))
)

# graph.render("graph.html")
graph.render_notebook()

精彩评论(0)

0 0 举报