Asset Diagnostics¶
The dartwork_mpl.diagnostics module bundles four 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 four helpers are also re-exported at the top level
(dm.classify_colormap, dm.plot_colormaps, dm.plot_colors,
dm.plot_fonts) and from dartwork_mpl.explore. They were
previously housed in dartwork_mpl.asset_viz, which still
works but emits a DeprecationWarning (see Migration Guide).
Quick examples¶
import dartwork_mpl as dm
import matplotlib as mpl
# Group colormaps by category and render one figure per group
figs = dm.plot_colormaps(group_by_type=True, ncols=4)
# Preview every named color, one figure per design system
figs = dm.plot_colors(ncols=5, show_hex=True)
# Audit registered font families with weight + italic spectrum
fig = dm.plot_fonts(font_size=11, ncols=3)
# Classify an arbitrary colormap
dm.classify_colormap(mpl.colormaps["coolwarm"]) # → "Diverging"
For a click-and-copy palette browser without leaving the docs, see the interactive palette explorer. For a colormap browser, see the colormap explorer.
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.plot_colormaps(cmap_list: list[str] | list[Colormap] | None = None, ncols: int = 3, group_by_type: bool = True) list[Figure][source]
Plot 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.plot_colors(colors: dict[str, str | tuple[float, float, float]] | None = None, *, ncols: int = 4, sort_colors: bool = True, show_hex: bool = True) list[Figure][source]
Plot 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
- 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
Module Reference¶
Asset diagnostics — visualize registered colormaps, colors, and fonts.
This package houses the four visualization helpers that inspect the available dartwork-mpl assets:
classify_colormap()— categorize a matplotlib colormap.plot_colormaps()— render registered colormaps grouped by type.plot_colors()— render named color libraries (OpenColor, Tailwind, Material Design, etc.) 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); import from this package (or the top-level
dartwork_mpl namespace) rather than the submodules directly.
These functions used to live in the dartwork_mpl.asset_viz
subpackage. That import path still works but emits a
DeprecationWarning.
- dartwork_mpl.diagnostics.classify_colormap(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_colormaps(cmap_list: list[str] | list[Colormap] | None = None, ncols: int = 3, group_by_type: bool = True) list[Figure][source]
Plot 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.plot_colors(colors: dict[str, str | tuple[float, float, float]] | None = None, *, ncols: int = 4, sort_colors: bool = True, show_hex: bool = True) list[Figure][source]
Plot 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
- 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