Skip to content

Commit

Permalink
Added offset
Browse files Browse the repository at this point in the history
  • Loading branch information
cvanelteren committed Sep 27, 2023
1 parent 63a659a commit e0e7eaa
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions networkx/drawing/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -1220,7 +1220,9 @@ def arf_layout(
return dict(zip(G.nodes(), p))


def arc_layout(G: nx.Graph, subset_key="subset", radius=1, rotation=0) -> dict:
def arc_layout(
G: nx.Graph, subset_key="subset", radius=1, rotation=0, offset=0
) -> dict:
"""Arc layout for networkx
Provides a layout where a multipartite graph is
Expand All @@ -1237,6 +1239,8 @@ def arc_layout(G: nx.Graph, subset_key="subset", radius=1, rotation=0) -> dict:
Radius of the unit circle
rotation : float
Rotation of the axes of the unit circle
offset : float
Offset for the first node in the spoke
Returns
-------
Expand All @@ -1258,7 +1262,7 @@ def arc_layout(G: nx.Graph, subset_key="subset", radius=1, rotation=0) -> dict:
for category, angle in zip(categories, angles):
# collect nodes
subset = [node for node, attr in attrs.items() if attr == category]
radii = np.linspace(0, radius, len(subset), 0)
radii = np.linspace(offset, radius, len(subset), 0)
for node, rad in zip(subset, radii):
pos[node] = rad * np.array([np.cos(angle), np.sin(angle)])
return pos
Expand Down

0 comments on commit e0e7eaa

Please sign in to comment.