如何用litstudy生成布局合理的静态网络图?
问题:生成布局合理的静态合著网络图
问题背景
使用litstudy模块加载Scopus导出的学术论文属性CSV文件,构建合著网络并绘图(绘图依赖pyvis模块)时遇到以下问题:
- 交互式模式下网络图布局良好,但节点会随意移动,不利于分析
- 将
litstudy.network.plot_network()的interactive参数设为False后,节点出现严重重叠
期望得到布局合理的静态网络图。
尝试的代码
soc_path = ( r'C:/Documents/Post_Doc/Writing_and_Learning/Lit_Review/Web_of_Science_Seagrass_Organic_Carbon.csv' ) hab_path = ( r'C:/Documents/Post_Doc/Writing_and_Learning/Lit_Review/Web_of_Science_Seagrass_Habitat_Mapping.csv' ) def scopus_doc_generator(path):# , year docs = litstudy.load_scopus_csv(path.replace('.csv', '_amended.csv')) #docs_refined = docs.filter_docs(lambda d: d.publication_year >= year) docs_found, docs_not_found = litstudy.refine_crossref(docs) return docs_found soc_docs_found = scopus_doc_generator(soc_path) #, 2000 hab_map_docs_found = scopus_doc_generator(hab_path) #, 2000 total_docs_found = soc_docs_found | hab_map_docs_found coauthor_network = litstudy.build_coauthor_network(total_docs_found) litstudy.network.plot_network( coauthor_network, max_node_size = 75, interactive = False )
解决方法
- 修改pyvis的
template.html文件 - 在litstudy的
network.py文件的plot_network函数中添加以下代码:
template_dir = '你保存修改后template.html文件的路径' v.set_template_dir(template_dir) return v.show(file_name)
内容的提问来源于stack exchange,提问作者GeologicalInvestigator
相关产品推荐
相关产品推荐

