fastplotlib.utils#
- calculate_figure_shape(n_subplots)[source]#
Returns
(n_rows, n_cols)
from given number of subplotsn_subplots
- make_colors(n_colors, cmap, alpha=1.0)[source]#
Get colors from a colormap. The returned colors are uniformly spaced, except for qualitative colormaps where they are returned subsequently.
- make_colors_dict(labels, cmap, **kwargs)[source]#
Get a dict for mapping labels onto colors.
- Parameters:
labels (Sequence[Any]) – labels for creating a colormap. Order is maintained if it is a list of unique elements.
cmap (str) – name of colormap
**kwargs – passed to make_colors()
- Returns:
keys are labels, values are colors
- Return type:
OrderedDict
Examples
from fastplotlib.utils import get_colors_dict labels = ["l1", "l2", "l3"] labels_cmap = get_colors_dict(labels, cmap="tab10") # illustration of what the `labels_cmap` dict would look like: # keep in mind that the tab10 cmap was chosen here { "l1": <RGBA array for the blue 'tab10' color>, "l2": <RGBA array for the orange 'tab10' color>, "l3": <RGBA array for the green 'tab10' color>, } # another example with a non-qualitative cmap labels_cmap_seismic = get_colors_dict(labels, cmap="bwr") { "l1": <RGBA array for the blue 'bwr' color>, "l2": <RGBA array for the white 'bwr' color>, "l3": <RGBA array for the red 'bwr' color>, }