holoviz / holoviz/hvplot

Control labels position when plotting Networkx

Open
#558 2 comments 0 reactions 0 assignees View on GitHub
interface: networkx
Dominant language
Python
Stars
1.4k
Forks
124
Avg merge
1d 18h
Merged PRs (30d)
1

Description

#### Is your feature request related to a problem? Please describe.
When plotting a graph (given as a Networkx object), there's no easy control on the position of the labels.

```python
G = nx.DiGraph()
G.add_node("a")
G.add_node("b")
G.add_edge("a", "b")
pos = nx.layout.planar_layout(G)
nodes = hvnx.draw_networkx_nodes(
G, pos, with_labels=True
)
edges = hvnx.draw_networkx_edges(
G, pos, arrowstyle="->"
)
nodes * edges
```

Based on the suggestion by @philippjfr [see here](https://discourse.holoviz.org/t/labels-position-when-plotting-netwrokx/1211/4), adding `.opts('Labels', xoffset=.0, yoffset=.09)` to the nodes drawing controls the position of the labels.

This is working as expected but probably could be part of the drawing function itself.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.