psynlig.colors

A module defining helper methods for setting up colors.

psynlig.colors.generate_class_colors(class_data, cmap=None)[source]

Generate colors for classes.

Parameters
  • class_data (object like numpy.ndarray or None) – The class labels for the data points. This is here assumed to be numerical values. If None are given we do not generate any colors here.

  • cmap (string or object like matplotlib.colors.Colormap, optional) – A color map to use for the classes.

Returns

  • color_class (list of objects like numpy.ndarray) – A list containing the colors generated here for the classes.

  • color_labels (dict of objects like numpy.ndarray) – Colors for the different classes, that is color_labels[i] contains the color for class i.

  • idx_class (dict of integers) – Indices for data classes. That is idx_class[i] contains the indices for the points in class_data which belongs to class i.

psynlig.colors.generate_colors(ncolors, cmap=None)[source]

Generate distinct colors.

Parameters
  • ncolors (integer) – The number of colors to generate.

  • cmap (string or object like matplotlib.colors.Colormap, optional) – A specific color map to use. If not provided, a color map is selected based on the number of colors: If the number of colors is less than 10, we will use tab10; if the number is between 11 and 20, we will use tab20; otherwise, we will use viridis.

Returns

out (list of objects like numpy.ndarray) – The colors generated.