Python绘制桑基图Sankey,Pyecharts不显示html页面,桑基图只显示标题,原因总结 您所在的位置:网站首页 pyecharts不报错但是不显示图 Python绘制桑基图Sankey,Pyecharts不显示html页面,桑基图只显示标题,原因总结

Python绘制桑基图Sankey,Pyecharts不显示html页面,桑基图只显示标题,原因总结

#Python绘制桑基图Sankey,Pyecharts不显示html页面,桑基图只显示标题,原因总结 | 来源: 网络整理| 查看: 265

Python绘制桑基图Sankey,Pyecharts不显示html页面,桑基图只显示标题,原因总结

说说使用上的三点注意:

1.nodes中的"name"不要重新命名,否则会不识别,导致没有图

2.links中source和target对应的值一定要在nodes的name对应的值中,否则图中会不显示(但是不会报错)

3.links中source和target对应的值不能相同,否则图不显示

主要参考: 桑基图官方文档

12345678910111213141516171819202122232425262728293031# official from pyecharts import options as opts from pyecharts.charts import Sankey nodes = [     {"name": "category1"},     {"name": "category2"},     {"name": "category3"},     {"name": "category4"},     {"name": "category5"},     {"name": "category6"}, ] links = [     {"source": "category1", "target": "category2", "value": 10},     {"source": "category2", "target": "category3", "value": 15},     {"source": "category3", "target": "category4", "value": 20},     {"source": "category5", "target": "category6", "value": 25}, ] c = (     Sankey()     .add(         "sankey",         nodes,         links,         linestyle_opt=opts.LineStyleOpts(opacity=0.2, curve=0.5, color="source"),         label_opts=opts.LabelOpts(position="right"),     )     .set_global_opts(title_opts=opts.TitleOpts(title="Sankey-基本示例"))     .render("sankey_base.html") )

参考1:Pyecharts 1.7.0制作图表,运行生成的html文件用浏览器打开空白问题(以桑基图为例) 主要用于无法访问html中的"https://assets.pyecharts.org/assets/echarts.min.js",可在无法联网时使用 方法为:手动定制下载echarts.min.js,复制到本地,然后修改.html文件 “https://assets.pyecharts.org/assets/echarts.min.js"为相对路径”./echarts.min.js"



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有