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

pyecharts Graph关系图示例_第1张图片 

 

你可能感兴趣的:(pyecharts Graph关系图示例)