Python画和弦图
程序员文章站
2022-12-20 23:18:31
import pandas as pdfrom bokeh.charts import output_file, Chordfrom bokeh.io import showfrom bokeh.sampledata.les_mis import datanodes = data['nodes']links = data['links']nodes_df = pd.DataFrame(nodes)links_df = pd.DataFrame(links)source_data = ....
import pandas as pd
from bokeh.charts import output_file, Chord
from bokeh.io import show
from bokeh.sampledata.les_mis import data
nodes = data['nodes']
links = data['links']
nodes_df = pd.DataFrame(nodes)
links_df = pd.DataFrame(links)
source_data = links_df.merge(nodes_df, how='left', left_on='source', right_index=True)
source_data = source_data.merge(nodes_df, how='left', left_on='target', right_index=True)
source_data = source_data[source_data["value"] > 5]
source_data
chord_from_df = Chord(source_data, source="name_x", target="name_y", value="value")
output_file('chord-diagram-bokeh.html', mode="inline")
show(chord_from_df)
本博主新开公众号, 希望大家能扫码关注一下,十分感谢大家。
本文来自:https://github.com/holtzy/The-Python-Graph-Gallery/blob/master/PGG_notebook.py
本文地址:https://blog.csdn.net/weixin_41869644/article/details/107446097
上一篇: 李国庆回应“抢公章”:依法接管 没有撕扯
下一篇: ai怎么画简笔画小铃铛? ai铃铛的画法