igviz package

Subpackages

Submodules

igviz.igviz module

class igviz.igviz.PlotGraph(G: Graph, layout: str)

Bases: object

generate_edge_traces(edge_label: str, edge_label_position: str, edge_text: List[str]) Tuple[Scatter, Scatter]

Generates the edge traces for the graph.

Parameters

edge_label (str, optional) – Edge property to be shown on the edge.

edge_label_position: str, optional

Position of the edge label. Either {‘top left’, ‘top center’, ‘top right’, ‘middle left’,

‘middle center’, ‘middle right’, ‘bottom left’, ‘bottom center’, ‘bottom right’}

edge_textlist, optional

A list of edge properties to display when hovering over the edge.

Returns

Lines and invisible nodes for the edges.

Return type

Tuple[go.Scatter, go.Scatter]

generate_figure(node_trace: Scatter, edge_trace: Scatter, middle_node_trace: Scatter, title: str, titlefont_size: int, showlegend: bool, annotation_text, arrow_size: int, transparent_background: bool, highlight_neighbours_on_hover: bool)

Helper function to generate the figure for the Graph.

generate_node_traces(colorscale: str, colorbar_title: str, color_method: Union[str, List[str]], node_label: str, node_text: List[str], node_label_position: str, node_opacity: float, size_method: Union[str, List[str]])
on_hover(trace: Scatter, points: Points, input_device_state: InputDeviceState)

Callback function for when a node is hovered over.

Parameters
  • trace (go.Scatter) – Figure trace for the node.

  • points (callbacks.Points) – Points that are hovered over.

  • input_device_state (callbacks.InputDeviceState) – Input device state, e.g. what keys were pressed

on_unhover(trace: Scatter, points: Points, input_device_state: InputDeviceState)

Callback function for when a node is unhovered over.

Parameters
  • trace (go.Scatter) – Figure trace for the node.

  • points (callbacks.Points) – Points that are hovered over.

  • input_device_state (callbacks.InputDeviceState) – Input device state, e.g. what keys were pressed

igviz.igviz.plot(G, title: str = 'Graph', layout: Optional[str] = None, size_method: str = 'degree', color_method: str = 'degree', node_label: Optional[str] = None, node_label_position: str = 'bottom center', node_text: Optional[List[str]] = None, edge_label: Optional[str] = None, edge_label_position: str = 'middle center', edge_text: Optional[List[str]] = None, titlefont_size: int = 16, showlegend: bool = False, annotation_text: Optional[str] = None, colorscale: str = 'YlGnBu', colorbar_title: Optional[str] = None, node_opacity: float = 0.8, arrow_size: int = 2, transparent_background: bool = True, highlight_neighbours_on_hover: bool = True)

Plots a Graph using Plotly.

Parameters
  • G (Networkx Graph) – Network Graph

  • title (str, optional) – Title of the graph, by default “Graph”

  • layout ({"random", "circular", "kamada", "planar", "spring", "spectral", "spiral"}, optional) –

    Layout of the nodes on the plot.

    random (default): Position nodes uniformly at random in the unit square.

    For every node, a position is generated by choosing each of dim coordinates uniformly at random on the interval [0.0, 1.0).

    circular: Position nodes on a circle.

    kamada: Position nodes using Kamada-Kawai path-length cost-function.

    planar: Position nodes without edge intersections, if possible (if the Graph is planar).

    spring: Position nodes using Fruchterman-Reingold force-directed algorithm.

    spectral: Position nodes using the eigenvectors of the graph Laplacian.

    spiral: Position nodes in a spiral layout.

  • size_method ({'degree', 'static'}, node property or a list, optional) –

    How to size the nodes., by default “degree”

    degree: The larger the degree, the larger the node.

    static: All nodes are the same size.

    node property: A property field of the node.

    list: A list pertaining to the size of the nodes.

  • color_method ({'degree'}, hex color code, node property, or list optional) –

    How to color the node., by default “degree”

    degree: Color the nodes based on their degree.

    hex color code: Hex color code.

    node property: A property field of the node.

    list: A list pertaining to the colour of the nodes.

  • node_label (str, optional) – Node property to be shown on the node.

  • node_label_position (str, optional) –

    Position of the node label. Either {‘top left’, ‘top center’, ‘top right’, ‘middle left’,

    ’middle center’, ‘middle right’, ‘bottom left’, ‘bottom center’, ‘bottom right’}

  • node_text (list, optional) – A list of node properties to display when hovering over the node.

  • edge_text (list, optional) – A list of edge properties to display when hovering over the edge.

  • edge_label (str, optional) – Edge property to be shown on the edge.

  • edge_label_position (str, optional) –

    Position of the edge label. Either {‘top left’, ‘top center’, ‘top right’, ‘middle left’,

    ’middle center’, ‘middle right’, ‘bottom left’, ‘bottom center’, ‘bottom right’}

  • titlefont_size (int, optional) – Font size of the title, by default 16

  • showlegend (bool, optional) – True to show legend, by default False

  • annotation_text (str, optional) – Graph annotation text, by default None

  • colorscale ({'Greys', 'YlGnBu', 'Greens', 'YlOrRd', 'Bluered', 'RdBu', 'Reds', 'Blues', 'Picnic', 'Rainbow', 'Portland', 'Jet', 'Hot', 'Blackbody', 'Earth', 'Electric', 'Viridis'}) – Scale of the color bar

  • colorbar_title (str, optional) – Color bar axis title, by default None

  • node_opacity (int, optional) – Opacity of the nodes (1 - filled in, 0 completely transparent), by default 1

  • arrow_size (int, optional) – Size of the arrow for Directed Graphs and MultiGraphs, by default 2.

  • transparent_background (bool, optional) – True to have a transparent background, by default True

  • highlight_neighbours_on_hover (bool, optional) – True to highlight the neighbours of a node on hover, by default True

Returns

Plotly figure of the graph

Return type

Plotly Figure

Module contents