Asset Diagnostics¶
The dartwork_mpl.diagnostics module bundles helpers that
let you inspect exactly 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.
The Model B color-family preview is available as dm.show_colors. The
diagnostic color-library and colormap catalog renderers live under
dartwork_mpl.diagnostics. Upgrading from an older alias path? See the
Migration Guide.
Quick examples¶
import dartwork_mpl as dm
import matplotlib as mpl
from dartwork_mpl import diagnostics
# Group colormaps by category and render one figure per group
figs = diagnostics.render_cmap_catalog(group_by_type=True, ncols=4)
# Preview Model B color families
fig = dm.show_colors(kind="qualitative")
# Audit registered font families with weight + italic spectrum
fig = dm.plot_fonts(font_size=11, ncols=3)
# Classify an arbitrary colormap
diagnostics.classify_cmap(mpl.colormaps["coolwarm"]) # → "Diverging"
dm.show_colors previews the registered Model B families. Browse the full
token sheets in Colors, choose series palettes
in Palettes, and inspect continuous maps in
the Colormaps catalog.
Choosing the right helper¶
Goal |
Helper |
|---|---|
“What named colors do I have available?” |
|
“Which colormaps come bundled, by category?” |
|
“Are my Korean / CJK fonts registered?” |
|
“Is this colormap sequential, diverging, or cyclical?” |
|
“I just want a Python list, not a figure” |
|
API¶
- dartwork_mpl.show_colors(kind: Literal['sequential', 'multi-hue', 'diverging', 'cyclic', 'qualitative'] | str | None = None, names: Iterable[str] | None = None, n: int | None = None) Figure[source]
Return a compact preview figure for Model B color families.
- dartwork_mpl.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/fontdirectory 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.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
Module Reference¶
Asset diagnostics for registered colormaps, colors, and fonts.
This package houses visualization helpers that inspect the available dartwork-mpl assets:
classify_cmap()— categorize a matplotlib colormap.render_cmap_catalog()— render registered colormaps grouped by type.render_color_catalog()— render named color libraries as swatch grids.plot_fonts()— render registered font families with weight spectrum and pangram samples.
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/fontdirectory 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
_rreversed 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