需要安装pyecharts

pip install pyecharts -U

pyecharts第五节、关系图_echarts

创建【demo5.py】测试类

pyecharts第五节、关系图_测试类_02

pyecharts第五节、关系图_图像处理_03 

输入以下编码:

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

执行:

pyecharts第五节、关系图_html_04

打开生成文件:

pyecharts第五节、关系图_图像处理_05

pyecharts第五节、关系图_图像处理_06 

效果图如下:

pyecharts第五节、关系图_echarts_07

希望能对大家有所帮助。