tanat.visualization.utils package#

Submodules#

tanat.visualization.utils.color_manager module#

ColorManager: assigns colors to categorical labels.

Accepts a colormap spec (string, dict, or list of hex strings) and a list of labels, then returns a dict mapping each label to a hex color string.

class tanat.visualization.utils.color_manager.ColorManager[source]#

Bases: object

Assigns matplotlib colors to categorical labels.

Colormap spec formats: - str -> named matplotlib colormap (e.g. “tab10”, “Set2”). - dict -> explicit label-to-color mapping. - list[str] -> explicit color cycle; wraps around if more labels than colors. - None -> defaults to “tab10”.

static build(labels: list, spec: str | dict | list | None = None) dict[source]#

Return a {label: hex_color} dict for every label in labels.

Parameters:
  • labels – Unique category labels (order determines color assignment when spec is a cmap name or list).

  • spec – Color specification (see class docstring).

Returns:

Dict mapping each label to a hex color string.

Raises:

ValueError – If spec is a dict and some labels are missing.

tanat.visualization.utils.result module#

VisualizationResult: wraps a matplotlib Figure for display and export.

class tanat.visualization.utils.result.VisualizationResult(fig: Figure)[source]#

Bases: object

Lightweight wrapper around a matplotlib Figure.

Example:

result = visualizer.draw(pool)
result.show()
result.save("output/barplot.png", dpi=150)
__init__(fig: Figure) None[source]#
property figure: Figure[source]#

The underlying matplotlib Figure.

save(path: str | Path, *, dpi: int = 150, **kwargs) None[source]#

Save the figure to path.

Parameters:
  • path – Destination file path. Format inferred from extension.

  • dpi – Resolution in dots per inch.

  • **kwargs – Forwarded to savefig().

show() None[source]#

Display the figure (calls matplotlib.pyplot.show()).

Module contents#

Visualization utilities.

class tanat.visualization.utils.ColorManager[source]#

Bases: object

Assigns matplotlib colors to categorical labels.

Colormap spec formats: - str -> named matplotlib colormap (e.g. “tab10”, “Set2”). - dict -> explicit label-to-color mapping. - list[str] -> explicit color cycle; wraps around if more labels than colors. - None -> defaults to “tab10”.

static build(labels: list, spec: str | dict | list | None = None) dict[source]#

Return a {label: hex_color} dict for every label in labels.

Parameters:
  • labels – Unique category labels (order determines color assignment when spec is a cmap name or list).

  • spec – Color specification (see class docstring).

Returns:

Dict mapping each label to a hex color string.

Raises:

ValueError – If spec is a dict and some labels are missing.

class tanat.visualization.utils.VisualizationResult(fig: Figure)[source]#

Bases: object

Lightweight wrapper around a matplotlib Figure.

Example:

result = visualizer.draw(pool)
result.show()
result.save("output/barplot.png", dpi=150)
__init__(fig: Figure) None[source]#
property figure: Figure[source]#

The underlying matplotlib Figure.

save(path: str | Path, *, dpi: int = 150, **kwargs) None[source]#

Save the figure to path.

Parameters:
  • path – Destination file path. Format inferred from extension.

  • dpi – Resolution in dots per inch.

  • **kwargs – Forwarded to savefig().

show() None[source]#

Display the figure (calls matplotlib.pyplot.show()).