pyecharts第五节、关系图

2022-11-29 18:54:44 浏览数 (1)

需要安装pyecharts

代码语言:javascript复制
pip install pyecharts -U

创建【demo5.py】测试类

输入以下编码:

代码语言:javascript复制
from pyecharts import options
from pyecharts.charts import Graph

nodes = [
    {"name": "星光点1", "symbolSize": 30},
    {"name": "暗影星2", "symbolSize": 30},
    {"name": "光芒星3", "symbolSize": 30},
    {"name": "闪耀星4", "symbolSize": 30},
    {"name": "纵横星5", "symbolSize": 30},
    {"name": "智慧星6", "symbolSize": 30}
]
links = []
for i in nodes:
    for j in nodes:
        links.append({"source": i.get("name"), "target": j.get("name")})

g = (
    Graph()
    .add("", nodes, links, repulsion=8000)
    .set_global_opts(title_opts=options.TitleOpts(title="六星光芒阵演示"))
    .render("guangmang.html")
)

执行:

打开生成文件:

效果图如下:

希望能对大家有所帮助。

0 人点赞