Visualization Module¶
Requires the viz extra (pip install "implicit-word-network[viz]").
implicit_word_network.visualization.plot_network
¶
plot_network(network: ImplicitNetwork | Graph, *, min_weight: float = 0.0, top_k: int | None = 100, labels: Sequence[str] | None = None, label_order: Sequence[str] | None = None, min_component_size: int = 1, ax: Any | None = None, layout: str = 'spring', seed: int = 42, node_size: tuple[float, float] = (90.0, 1100.0), edge_width: tuple[float, float] = (0.6, 5.5), with_labels: bool = True, max_labels: int | None = None, font_size: float = 8.5, legend: bool = True, palette: Sequence[str] = CATEGORICAL_PALETTE, title: str | None = None, output_path: str | None = None, show: bool = False) -> Any
Draw the entity layer of a network with matplotlib.
Node area scales with the number of mentions, edge width and opacity with the edge weight, and node colour encodes the entity type (fixed hue per type, listed in a legend). Labels are set in text ink with a surface halo and nudged apart so they do not overlap. Isolated entities are not drawn.
| PARAMETER | DESCRIPTION |
|---|---|
network
|
An
TYPE:
|
min_weight
|
Drop edges lighter than this (networks only).
TYPE:
|
top_k
|
Keep only the heaviest
TYPE:
|
labels
|
Restrict to these entity types (networks only).
TYPE:
|
label_order
|
Entity types in the order they take palette slots. Defaults to types sorted by total mentions (most frequent first).
TYPE:
|
min_component_size
|
Drop connected components with fewer nodes, so small satellites do not squeeze the main network into a corner.
TYPE:
|
ax
|
Matplotlib axes to draw on (a new figure is created otherwise).
TYPE:
|
layout
|
TYPE:
|
seed
|
Random seed of the spring layout.
TYPE:
|
node_size
|
Minimum and maximum node area in points².
TYPE:
|
edge_width
|
Minimum and maximum edge width in points.
TYPE:
|
with_labels
|
Draw entity names.
TYPE:
|
max_labels
|
Label only the
TYPE:
|
font_size
|
Label font size in points.
TYPE:
|
legend
|
Show the entity-type legend.
TYPE:
|
palette
|
Categorical colours, assigned to types in
TYPE:
|
title
|
Optional figure title.
TYPE:
|
output_path
|
Save the figure to this path when given.
TYPE:
|
show
|
Call
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Any
|
The matplotlib axes. |