我正在使用IBM作为云服务、jupyter记事本、Python3.9,并试图使用PyVis库呈现网络图。代码工作/没有错误,但图形/ html不会呈现,并返回“错误: 404未找到”和'openresty‘。
我使用'notebook=True‘选项,它应该在笔记本中呈现它。对于如何在Watson Studio Notebook环境(基于服务器)中呈现图形/图像/ html有任何帮助吗?
执行以下代码(取自PyVis教程),但不会在沃森工作室笔记本中呈现图形/图像。
from pyvis.network import Network
import pandas as pd
got_net = Network(height='750px', width='100%', bgcolor='#222222', font_color='white', notebook=True)
# set the physics layout of the network
got_net.barnes_hut()
got_data = pd.read_csv('https://www.macalester.edu/~abeverid/data/stormofswords.csv')
sources = got_data['Source']
targets = got_data['Target']
weights = got_data['Weight']
edge_data = zip(sources, targets, weights)
for e in edge_data:
src = e[0]
dst = e[1]
w = e[2]
got_net.add_node(src, src, title=src)
got_net.add_node(dst, dst, title=dst)
got_net.add_edge(src, dst, value=w)
neighbor_map = got_net.get_adj_list()
# add neighbor data to node hover data
for node in got_net.nodes:
node['title'] += ' Neighbors:<br>' + '<br>'.join(neighbor_map[node['id']])
node['value'] = len(neighbor_map[node['id']])
got_net.show('gameofthrones.html')发布于 2022-04-10 05:22:09
test - groupby('preds').sum()
to_vis = {}
for index in test.index:
temp = test.loc[[index]].T.sort_values(by=index, ascending=False)[:30].to_dict()
to_vis.update(temp)
g = Network(height='1000px', width='100%', notebook=True)
for cat, key_words in to_vis.items():
g.add_node(cat, size = 9, color = 'red')
for word in key_words:
g.add_node(word, size = 3)
g.add_edge(cat, word)https://stackoverflow.com/questions/71627048
复制相似问题