Plotting utils

A few useful helper functions

mesmerize.plotting.utils.get_colormap(labels: iter, cmap: str, **kwargs) → collections.OrderedDict[source]

Get a dict for mapping labels onto colors

Any kwargs are passed to auto_colormap()

Parameters:
  • labels – labels for creating a colormap. Order is maintained if it is a list of unique elements.
  • cmap – name of colormap
Returns:

dict of labels as keys and colors as values

mesmerize.plotting.utils.map_labels_to_colors(labels: iter, cmap: str, **kwargs) → list[source]

Map labels onto colors according to chosen colormap

Any kwargs are passed to auto_colormap()

Parameters:
  • labels – labels for mapping onto a colormap
  • cmap – name of colormap
Returns:

list of colors mapped onto the labels

mesmerize.plotting.utils.auto_colormap(n_colors: int, cmap: str = 'hsv', output: str = 'mpl', spacing: str = 'uniform') → List[Union[PyQt5.QtGui.QColor, numpy.ndarray]][source]

If non-qualitative map: returns list of colors evenly spread through the chosen colormap. If qualitative map: returns subsequent colors from the chosen colormap

Parameters:
  • n_colors – Numbers of colors to return
  • cmap – name of colormap
  • output – option: ‘mpl’ returns RGBA values between 0-1 which matplotlib likes, option: ‘pyqt’ returns QtGui.QColor instances that correspond to the RGBA values
  • spacing – option: ‘uniform’ returns evenly spaced colors across the entire cmap range option: ‘subsequent’ returns subsequent colors from the cmap
Returns:

List of colors as either QColor or numpy array with length n_colors