桑基图

Sankey(桑基图)

桑基图是一种特殊的流图, 它主要用来表示原材料、能量等如何从初始形式经过中间过程的加工、转化到达最终形式。

# 导入桑基图类
from pyecharts import Sankey
nodes = [
    {'name': '自己申请'}, {'name': '朋友推荐'}, {'name': '参加招聘会'},
    {'name': '上海'}, {'name': '南京'}, {'name': '杭州'},
    {'name': '面试'}, 
    {'name': '录用'}, {'name': '无响应'}, {'name': '拒绝'}
]

links = [
    {'source': '自己申请', 'target': '上海', 'value': 15},
    {'source': '自己申请', 'target': '南京', 'value': 15},
    {'source': '朋友推荐', 'target': '南京', 'value': 5},
    {'source': '自己申请', 'target': '杭州', 'value': 10},
    {'source': '参加招聘会', 'target': '杭州', 'value': 8},
    
    {'source': '上海', 'target': '无响应', 'value': 15},
    
    {'source': '南京', 'target': '无响应', 'value': 10},
    {'source': '南京', 'target': '面试', 'value': 10},
       
    {'source': '杭州', 'target': '无响应', 'value': 10},
    {'source': '杭州', 'target': '面试', 'value': 8},
    
    {'source': '面试', 'target': '录用', 'value': 5},
    {'source': '面试', 'target': '拒绝', 'value': 13}
]
sankey = Sankey("王小二找工作", width=1000, height=600)
sankey.add("", nodes, links,
           line_opacity=0.3,
           line_curve=0.5,
           line_color='source',
           is_random=True,
           is_label_show=True, label_pos='right')
# sankey.render()
sankey.render('王小二找工作.html')
import os
import json

from pyecharts import Sankey

with open("sankey.json", "r", encoding="utf-8") as f:
    j = json.load(f)
type(j)
dict
sankey = Sankey("桑基图示例", width=1200, height=600)
sankey.add("", nodes=j['nodes'], links=j['links'],
           line_opacity=0.2, line_curve=0.5, line_color='source',
           is_label_show=True, label_pos='right')
# sankey.render()
sankey
<div id="c9e070c481454582a4024698984ab30e" style="width:1200px;height:600px;"></div>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值