hvplot icon indicating copy to clipboard operation
hvplot copied to clipboard

Attribute 'connectionstyle' ignored, impossible to curve the graph edges.

Open agicquel opened this issue 4 years ago • 4 comments

ALL software version info

python 3.10 bokeh 2.4.2 networkx 2.6.2

Description of expected behavior and the observed behavior

I tried to draw directed graph along with the multipartite layout from networkx. The graph is rendered however all the edges overlap between each other. To correct this behavior, I added the 'connectionstyle' attribute in order to curve the edges in function draw_networkx_edges but the edges are still straight.

Complete, minimal, self-contained example code that reproduces the issue

defaults = dict(width=1600, height=1000)
hv.opts.defaults(opts.EdgePaths(**defaults), opts.Graph(**defaults), opts.Nodes(**defaults))pos = nx.layout.multipartite_layout(self.nx_cfg, subset_key="address", align="horizontal", scale=4)

nodes = hvnx.draw_networkx_nodes(self.nx_cfg, pos, node_size=30, node_color='blue')
edges = hvnx.draw_networkx_edges(self.nx_cfg, pos, node_size=30, arrows=True, arrowstyle=']->',
                                         arrowsize=10, edge_color="green", connectionstyle="arc3",
                                         edge_cmap='Blues', edge_width=2, colorbar=True)

show(hv.render(nodes * edges))

agicquel avatar Dec 03 '21 17:12 agicquel

Hi @agicquel, I believe the parameter connectionstyle is neither supported by hvplot nor by 'holoviews'.

This parameter is available in the function draw_networkx_edges provided by networkx (returning a Matplotlib object), but not by its equivalent function provided by hvplot. I don't think, but I'm not 100% sure, that this sort of styling is available in Bokeh.

Soon hvplot users will have the availability to use the Matplotlib backend instead of just Bokeh. I'm thus marking this issue as a feature request.

maximlt avatar Dec 06 '21 15:12 maximlt

Hi @maximlt and thanks for you reply. You're right, this option is only provided by networkx and Bokeh don't provide any option of this kind.

From my understanding, an edge is drawn using a path, i.e. a list of points in the graph. So, is it possible to provide a user function in the graph constructor to compute the desired path for each pair of nodes with an edge ?

agicquel avatar Dec 07 '21 08:12 agicquel

It looks like you can do that with holoviews by explicitly passing coordinates of each edge. I don't expect that to be trivial however, but I'd be happy if you can prove me wrong!

maximlt avatar Dec 08 '21 08:12 maximlt

Okay thank you. I'll let you know if I code something to make this easier!

agicquel avatar Dec 10 '21 16:12 agicquel