vivainsights.network_g2g¶
Create a network plot from a group-to-group query.
- vivainsights.network_g2g.network_g2g(data, primary=None, secondary=None, metric='Group_collaboration_time_invested', algorithm='fr', node_colour='lightblue', exc_threshold=0.1, org_count=None, node_scale=1, edge_scale=10, subtitle='Collaboration Across Organizations', figsize=None, return_type='plot')[source]¶
Return a network plot given a data frame containing a group-to-group query.
- Parameters:
data (pandas.DataFrame) – Data frame containing a group-to-group query.
primary (str, optional) – Variable name for the Primary Collaborator column. Auto-detected if
None.secondary (str, optional) – Variable name for the Secondary Collaborator column. Auto-detected if
None.metric (str) – Variable name for the collaboration metric. Defaults to
"Group_collaboration_time_invested".algorithm (str) – Node placement algorithm. Defaults to
"fr"(Fruchterman-Reingold).node_colour (str or dict) – Colour for displaying nodes. Defaults to
"lightblue". If"vary", a random colour is assigned to each node. A dictionary can map specific node names to colours.exc_threshold (float) – Exclusion threshold between 0 and 1. Defaults to 0.1 (collaboration below 10 %% of a node’s total is hidden). Has no impact on
"data"or"table"return.org_count (pandas.DataFrame, optional) – Data frame with two columns (group name and
"n") providing the size of each organization. Defaults toNone(fixed node sizes).node_scale (float) – Multiplier controlling node size. Defaults to 1.
edge_scale (float) – Multiplier controlling edge width. Defaults to 10.
subtitle (str) – Override for the default plot subtitle.
figsize (tuple, optional) – Figure size as
(width, height)in inches. Defaults to(8, 6).return_type (str) –
Type of output to return. Valid values:
"plot"(default): matplotlib Figure."table": interaction matrix as a DataFrame."network": igraph object."data": long-format DataFrame of underlying data.
- Returns:
Output depends on
return_type.- Return type:
matplotlib.figure.Figure, pandas.DataFrame, or igraph.Graph
Examples
>>> import vivainsights as vi >>> # Return a network visual >>> vi.network_g2g(data=vi.load_g2g_data(), metric="Group_meeting_count") >>> >>> # Return the interaction matrix >>> vi.network_g2g(data=vi.load_g2g_data(), return_type="table") >>> >>> # No exclusion threshold >>> vi.network_g2g(data=vi.load_g2g_data(), exc_threshold=0)