Diagnostics (dm.diagnostics)

Asset visualization helpers.

The dartwork_mpl.diagnostics module bundles helpers that let you inspect what colormaps, color libraries, and fonts are registered in your current environment. They render publication-quality preview figures without ever calling plt.show(), so they compose with your normal save / display pipeline.

Model B color previews live at dm.show_colors. Diagnostic color-library and colormap catalog renderers live under dartwork_mpl.diagnostics; font preview remains available as dm.plot_fonts. Upgrading from an older alias path? See the Migration Guide.

For richly-rendered swatch examples and the full narrative, see Asset Diagnostics. The page below is a thin autodoc shadow that matches the canonical module name.

API

Asset diagnostics for registered colormaps, colors, and fonts.

This package houses visualization helpers that inspect the available dartwork-mpl assets:

The implementation is split across _colormaps / _colors / _fonts submodules (#235).

These functions used to live in the dartwork_mpl.asset_viz subpackage; that import path was removed in 0.5.4.

dartwork_mpl.diagnostics.classify_cmap(cmap: Colormap) str[source]

Classify a colormap into one of the following categories.

Categories

  • Categorical

  • Single-Hue

  • Multi-Hue

  • Diverging

  • Cyclical

param cmap:

Colormap to classify.

type cmap:

matplotlib.colors.Colormap

returns:

Category of the colormap.

rtype:

str

dartwork_mpl.diagnostics.plot_fonts(font_dir: str | None = None, ncols: int = 2, font_size: int = 11) Figure[source]

Plot available font families with weight spectrum and samples.

Each font family is displayed as a titled section showing: - Family header with file count - Each weight rendered with pangram sample text - Italic variants shown inline with lighter color

Parameters:
  • font_dir (str, optional) – Directory path containing font files. If None, defaults to the asset/font directory within the package.

  • ncols (int, optional) – Number of columns to display font families, by default 2.

  • font_size (int, optional) – Font size for sample text, by default 11.

Returns:

fig – Figure object.

Return type:

matplotlib.figure.Figure

dartwork_mpl.diagnostics.render_cmap_catalog(cmap_list: list[str] | list[Colormap] | None = None, ncols: int = 3, group_by_type: bool = True) list[Figure][source]

Render colormaps grouped by type.

Returns a list of figures, one per category. Does not call plt.show() — the caller decides when to display.

Parameters:
  • cmap_list (list, optional) – List of colormap names or objects. Defaults to all registered colormaps (excluding _r reversed variants).

  • ncols (int, optional) – Number of columns, default 3.

  • group_by_type (bool, optional) – If True, group colormaps by their classified type and return one figure per category. Otherwise return a single figure.

Returns:

One figure per category (or a single-element list when group_by_type is False).

Return type:

list of matplotlib.figure.Figure

dartwork_mpl.diagnostics.render_color_catalog(colors: dict[str, str | tuple[float, float, float]] | None = None, *, ncols: int = 4, sort_colors: bool = True, show_hex: bool = True) list[Figure][source]

Render a grid of named colors with their names and hex values.

Creates separate figures for each color library (Open Color, Tailwind, Material Design, Ant Design, Chakra UI, Primer, Other).

Parameters:
  • colors (dict, optional) – Dictionary mapping color names to color specifications. If None, uses all named colors from matplotlib except those starting with 'dartwork_mpl.' or 'xkcd:'.

  • ncols (int, optional) – Number of columns in the color grid, default is 4.

  • sort_colors (bool, optional) – If True, sorts colors by base color name, then by weight or HSV value.

  • show_hex (bool, optional) – If True, shows the hex color value beneath each color name and overlaid on the swatch. Default True.

Returns:

List of figures, one for each color library.

Return type:

list of matplotlib.figure.Figure