Skip to main content
`Ctrl`+`K`

# spiral_layout

spiral_layout(G, scale=1, center=None, dim=2, resolution=0.35, equidistant=False)

  Position nodes in a spiral layout.

  Parameters:
    G NetworkX graph or list of nodes

      A position will be assigned to every node in G.

    scale number (default: 1)

      Scale factor for positions.

    center array-like or None

      Coordinate pair around which to center the layout.

    dim int, default=2

      Dimension of layout, currently only dim=2 is supported. Other dimension values result in a ValueError.

    resolution float, default=0.35

      The compactness of the spiral layout returned. Lower values result in more compressed spiral layouts.

    equidistant bool, default=False

      If True, nodes will be positioned equidistant from each other by decreasing angle further from center. If False, nodes will be positioned at equal angles from each other by increasing separation further from center.

  Returns:
    pos dict

      A dictionary of positions keyed by node

  Raises:
    ValueError

      If dim != 2

  Notes

  This algorithm currently only works in two dimensions.

  Examples

      >>> G = nx.path_graph(4)
      >>> pos = nx.spiral_layout(G)
      >>> nx.draw(G, pos=pos)