Plotting Utilities¶
- visual.plots_macros.create_barplot_encoded_image(edges: List[str], values: List[float], title: str | None = None, y_label: str | None = None, x_labebl: str | None = None) str[source]¶
Create a horizontal bar plot and return it as a base64-encoded PNG data URI.
- Parameters:
edges – List of labels for each bar (displayed on y-axis).
values – List of values corresponding to each bar.
title – Optional title for the plot. Defaults to None.
y_label – Optional label for the y-axis. Defaults to None.
x_labebl – Optional label for the x-axis (note: typo in parameter name). Defaults to None.
- Returns:
Base64-encoded PNG image as a data URI (data:image/png;base64,…).
- Return type:
str
- visual.plots_macros.create_graph_degree_distribution_encoded_image(degrees: List[int], bins: int = 20, title: str | None = None, log_scale: bool = False) str[source]¶
Create a degree distribution histogram and return it as a base64-encoded PNG data URI.
- Parameters:
degrees – List of degree values for all nodes in the network.
bins – Number of histogram bins. Defaults to 20.
title – Optional title for the plot. Defaults to None.
log_scale – If True, apply logarithmic scale to the y-axis. Defaults to False.
- Returns:
Base64-encoded PNG image as a data URI (data:image/png;base64,…).
- Return type:
str
- visual.plots_macros.create_scatter_plot_encoded_image(x_values: Sequence[float], y_values: Sequence[float], labels: Sequence[Any] | None = None, x_label: str = 'X', y_label: str = 'Y', title: str | None = None) str[source]¶
Create a scatter plot and return it as a base64-encoded PNG data URI.
Labels are automatically adjusted to reduce overlaps using the adjustText library.
- Parameters:
x_values – Sequence of x-axis coordinate values.
y_values – Sequence of y-axis coordinate values.
labels – Optional sequence of labels for each point. Defaults to None.
x_label – Label for the x-axis. Defaults to “X”.
y_label – Label for the y-axis. Defaults to “Y”.
title – Optional title for the plot. Defaults to None.
- Returns:
Base64-encoded PNG image as a data URI (data:image/png;base64,…).
- Return type:
str
- Raises:
ValueError – If x_values and y_values have different lengths.
ValueError – If labels are provided but have a different length than x_values.