Visualization Tools¶
Quick visual diagnostics for the assets bundled with dartwork-mpl. Use them to review palettes, pick colormaps by category, or validate fonts before building plots.
Example¶
dm.plot_colormaps(group_by_type=True) # Opens grouped figures
dm.plot_colors(ncols=5) # Shows named colors by library
dm.plot_fonts(font_size=10) # Preview installed font families
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