🎨 Visualization¶
Submodules¶
Usage note¶
Visualization helpers return axes/figures and do not call plt.show() by default. Use the show=True argument or call plt.show() explicitly when needed.
hypergraphx.viz.draw_communities module¶
- hypergraphx.viz.draw_communities.draw_communities(hypergraph, u, col, figsize=(7, 7), ax=None, pos=None, edge_color='lightgrey', edge_width=0.3, threshold_group=0.1, wedge_color='lightgrey', wedge_width=1.5, with_node_labels=True, label_size=10, label_col='black', node_size=None, c_node_size=0.004, title=None, title_size=15, seed=20, scale=2, iterations=100, opt_dist=0.2, show=False)[source]¶
- hypergraphx.viz.draw_communities.extract_pie_properties(i, u, colors, threshold=0.1)[source]¶
Given a node, it extracts the wedge sizes and the respective colors for the pie chart that represents its membership.
- Parameters:
i (node id.)
u (membership matrix.)
colors (dictionary of colors, where key represent the group id and values are colors.)
threshold (threshold for node membership.)
- Returns:
wedge_sizes (wedge sizes.)
wedge_colors (sequence of colors through which the pie chart will cycle.)
hypergraphx.viz.draw_hypergraph module¶
- hypergraphx.viz.draw_hypergraph.draw_hypergraph(hypergraph, figsize=(12, 7), ax=None, pos=None, edge_color='lightgrey', hyperedge_color_by_order=None, hyperedge_facecolor_by_order=None, edge_width=1.2, hyperedge_alpha=0.8, node_size=150, node_color='#E2E0DD', node_facecolor='black', node_shape='o', with_node_labels=False, label_size=10, label_col='black', seed=10, scale=1, iterations=100, opt_dist=0.5, show=False)[source]¶
Visualize a hypergraph.
- Parameters:
show (bool) – If True, call plt.show().
- Returns:
The axes the plot was drawn on.
- Return type:
matplotlib.axes.Axes
hypergraphx.viz.draw_multilayer_projection module¶
hypergraphx.viz.draw_projections module¶
- hypergraphx.viz.draw_projections.draw_bipartite(h, pos=None, ax=None, align='vertical', show=False, **kwargs)[source]¶
Draws a bipartite graph representation of the hypergraph. :param h: The hypergraph to be projected. :type h: Hypergraph. :param pos: A dictionary with nodes as keys and positions as values. :type pos: dict. :param ax: The axes to draw the graph on. :type ax: matplotlib.axes.Axes. :param kwargs: Keyword arguments to be passed to networkx.draw_networkx. :type kwargs: dict. :param align: The alignment of the nodes. Can be ‘vertical’ or ‘horizontal’. :type align: str. :param show: If True, call plt.show(). :type show: bool.
- Returns:
ax – The axes the graph was drawn on.
- Return type:
matplotlib.axes.Axes.
- hypergraphx.viz.draw_projections.draw_clique(h, pos=None, ax=None, show=False, **kwargs)[source]¶
Draws a clique projection of the hypergraph. :param h: The hypergraph to be projected. :type h: Hypergraph. :param pos: A dictionary with nodes as keys and positions as values. :type pos: dict. :param ax: The axes to draw the graph on. :type ax: matplotlib.axes.Axes. :param kwargs: Keyword arguments to be passed to networkx.draw_networkx. :type kwargs: dict. :param show: If True, call plt.show(). :type show: bool.
- Returns:
ax
- Return type:
matplotlib.axes.Axes. The axes the graph was drawn on.
hypergraphx.viz.draw_motifs module¶
- hypergraphx.viz.draw_motifs.draw_motifs(patterns, edge_size_colors=None, node_labels=None, node_size=500, node_color='lightblue', edge_color='black', save_path=None, axes=None, figsize=None, tight_layout=True, show=False)[source]¶
Draw a list of motif patterns side by side.
- Parameters:
patterns (list) – List of motif hypergraphs, each expressed as a list of hyperedges.
axes (matplotlib.axes.Axes or list, optional) – Axes to draw on. If provided, its length must match the number of patterns.
figsize (tuple, optional) – Figure size used only when axes is None.
tight_layout (bool) – If True, call plt.tight_layout().
show (bool) – If True, call plt.show().
- Returns:
fig (matplotlib.figure.Figure)
axes (list[matplotlib.axes.Axes])
hypergraphx.viz.draw_simplicial module¶
- hypergraphx.viz.draw_simplicial.draw_simplicial(HG, pos=None, link_color='black', hyperlink_color_by_order=None, link_width=2, node_size=150, node_color='#5494DA', with_labels=False, ax=None, show=False)[source]¶
Draw a simplicial-complex-style visualization for a hypergraph.
- Parameters:
show (bool) – If True, call plt.show().
- Returns:
The axes the plot was drawn on.
- Return type:
matplotlib.axes.Axes
hypergraphx.viz.plot_motifs module¶
- hypergraphx.viz.plot_motifs.plot_motifs(motifs, save_name=None, show=False, roman_numbers=False, motif_patterns=None, pos_color='#4C72B0', neg_color='#C44E52', blob_colors=None, icon_width=0.85, icon_y=0.86, icon_scale=0.95, icon_row_ylim=None, node_color='#222222', node_edge='white', node_size=30, edge_color='#333333', show_motif_labels=False, motif_labels=None, annotate_bars=False, annotate_fmt='{:+.2f}', hover_labels=False)[source]¶
Module contents¶
Visualization helpers.
This module is intentionally import-light: it should be safe to import even if optional plotting dependencies (e.g., matplotlib) are not installed. The actual implementations are imported lazily when the functions are called.