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. Parameters and return values are spelled out so you can skim and run.

plot_colormaps(cmap_list=None, ncols=3, group_by_type=True, group_spacing=0.5)
  • Parameters: - cmap_list: optional names/objects (defaults to all non-reversed maps). - ncols: grid width. - group_by_type: split into Sequential/Diverging/etc. figures when True. - group_spacing: extra padding when showing a single grid.

  • Returns: - (fig, axs) from the last rendered figure.

plot_colors(ncols=5, sort_colors=True)
  • Parameters: - ncols: number of columns per grid. - sort_colors: order by hue/weight within each library.

  • Returns: - list of matplotlib.figure.Figure objects (one per library).

plot_fonts(font_dir=None, ncols=3, font_size=11)
  • Parameters: - font_dir: optional font directory. - ncols: number of columns in the preview grid. - font_size: sample size used in the preview.

  • Returns: - matplotlib.figure.Figure previewing the bundled or provided fonts.

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
dartwork_mpl.plot_colormaps(cmap_list: list[str] | list[Colormap] | None = None, ncols: int = 3, group_by_type: bool = True, group_spacing: float = 0.5) tuple[Figure, ndarray][source]

Plot a list of colormaps. When group_by_type=True, creates separate figures for each category and displays them automatically. Original source code: https://matplotlib.org/stable/users/explain/colors/colormaps.html

Parameters:
  • cmap_list (list, optional(default=None)) – List of colormap names.

  • ncols (int, optional(default=3)) – Number of columns to display colormaps.

  • group_by_type (bool, optional(default=True)) – If True, group colormaps by their type and create separate figures for each category. Each figure is automatically displayed.

  • group_spacing (float, optional(default=0.5)) – Spacing between groups in inches (unused when group_by_type=True).

Returns:

  • fig (matplotlib.figure.Figure) – Figure object. When group_by_type=True, returns the last category’s figure.

  • axs (numpy.ndarray of matplotlib.axes.Axes) – Array of Axes objects. When group_by_type=True, returns the last category’s axes.

Examples

>>> fig, axs = plot_colormaps(['viridis', 'plasma', 'inferno'], ncols=3)
>>> plt.show()
>>> # Group by type - creates separate figures for each category
>>> fig, axs = plot_colormaps(ncols=3, group_by_type=True)
dartwork_mpl.plot_colors(colors: dict[str, str | tuple[float, float, float]] | None = None, *, ncols: int = 4, sort_colors: bool = True) list[Figure][source]

Plot a grid of named colors with their names.

Creates separate plots for each color library (opencolor, tw/tailwind, 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.’.

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

  • sort_colors (bool, optional) – If True, sorts colors by base color name (e.g., ‘neutral’, ‘red’, ‘blue’), and finally by number (small -> large) or HSV value (bright -> dark). Duplicate colors (same RGB values) are automatically removed. If False, uses the order from the input dictionary.

Returns:

List of figures, one for each color library.

Return type:

list of matplotlib.figure.Figure

Examples

>>> figs = plot_colors()
>>> plt.show()
>>> # Custom colors
>>> custom_colors = {'red': '#FF0000', 'green': '#00FF00', 'blue': '#0000FF'}
>>> figs = plot_colors(custom_colors, ncols=3)
>>> plt.show()
dartwork_mpl.plot_fonts(font_dir: str | None = None, ncols: int = 3, font_size: int = 11) Figure[source]

Plot available fonts in the specified directory.

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 3

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

Returns:

fig – Figure object

Return type:

matplotlib.figure.Figure