thevenin.plotutils#

A module designed to enhance plotting with the matplotlib library. Helper functions include routines for simplifying color scheme management, formatting axis ticks, fonts, and more, making it easier to create polished and consistent visualizations.

Functions#

get_colors(size[, data, norm, alpha, cmap])

Sample colors from 'cmap'.

Package Contents#

thevenin.plotutils.get_colors(size, data=None, norm=None, alpha=1.0, cmap='jet')[source]#

Sample colors from ‘cmap’.

Return a list of colors from a specified colormap. Default options will provide evenly spaced colors across ‘cmap’. Provide ‘data’ and/or ‘norm’ to control the ordering, spacing, and normalization.

Parameters:
  • size (int) – Number of colors to return.

  • data (array_like[float] or None, optional) – A 1D array with length ‘size’ that controls the spacing and sorting of the output. By default, spacing is equal and sorting matches ‘cmap’.

  • norm (array_like[float] or None, optional) – An array-like (min, max) pair that normalizes the colormap to ‘data’. By default (0, size) if ‘data=None’ or min/max of ‘data’ otherwise.

  • alpha (float, optional) – Transparency to apply over the colormap. Must be in the range [0, 1]. The default is 1.

  • cmap (str, optional) – A valid matplotlib colormap name. The default is ‘jet’.

Returns:

colors (list) – A list of (r, g, b, a) color codes.

Raises:
  • ValueError – ‘data’ length must match ‘size’.

  • ValueError – ‘norm’ length must equal 2.