1

我想知道 Pyvis 是否有可能在节点之间有一条直线?就像不同节点之间的分层链接。

我的代码:

from pyvis.network import Network

net = Network(notebook=True, height = 1000, width = 2000, font_color="black", bgcolor ='black', heading='Network Alto')


# net.show_buttons(filter_=   ['configure','layout','interaction','physics','edges'])

net.add_node('EXCESS RET. 1.0%', shape='box', color = '#e40513')
net.add_node('CARRY 2.8%', shape='box', color = '#716f71')
net.add_node('MOMEMTUM -1.7%', shape='box', color = '#d06a26')
net.add_node('VALUE -0.1%', shape='box', color = '#018480')

# Subdimensions
net.add_node('EQUITIES -0.1%', shape='box', color = '#499a35')
net.add_node('BONDS -0.1%', shape='box', color = '#01a3e1')
net.add_node('CURRENCIES -0.1%', shape='box', color = '#9750e3')


net.add_edge('EXCESS RET. 1.0%','CARRY 2.8%',color='white')
net.add_edge('EXCESS RET. 1.0%','MOMEMTUM -1.7%',color='white')
net.add_edge('EXCESS RET. 1.0%','VALUE -0.1%',color='white')

net.add_edge('CARRY 2.8%','EQUITIES -0.1%',color='white')
net.add_edge('CARRY 2.8%','BONDS -0.1%',color='white')
net.add_edge('CARRY 2.8%','CURRENCIES -0.1%',color='white')

net.set_options("""var options = {
  "edges": {
    "color": {
      "inherit": true
    },
    "smooth": false
  },
  "layout": {
    "hierarchical": {
      "enabled": true,
      "levelSeparation": 200,
      "nodeSpacing": 60,
      "direction": "LR",
      "sortMethod": "directed"
    }
  },
  "physics": {
    "hierarchicalRepulsion": {
      "centralGravity": 0
    },
    "minVelocity": 0.75,
    "solver": "hierarchicalRepulsion"
  }
}""")

net.show("basic.html")

如果可能的话,我想要这种风格的线条:

在此处输入图像描述

4

0 回答 0