sqfa.plot.colors

Functions for working with colors and colormaps.

Functions

draw_color_bar(colormap, limits, fig[, title])

Draw a color bar for the given colormap and limits.

get_class_rgba(color_map, values[, color_limits])

Get the RGBA color for each class based on the colormap and the values.

get_normalized_color_map(color_map, values)

Get the color map and normalizer for the given values.

sqfa.plot.colors.draw_color_bar(colormap, limits, fig, title=None)

Draw a color bar for the given colormap and limits.

Parameters:
  • colormap (str or matplotlib.colors.Colormap) – The colormap to use.

  • limits (list) – The minimum and maximum values for the color scale.

  • fig (matplotlib.figure.Figure) – The figure to draw the color bar on.

Returns:

color_bar – The created color bar.

Return type:

ColorbarBase

sqfa.plot.colors.get_class_rgba(color_map, values, color_limits=None)

Get the RGBA color for each class based on the colormap and the values.

Parameters:
  • color_map (str or matplotlib.colors.Colormap) – The colormap to use.

  • values (list or numpy.ndarray or torch.Tensor) – The value of each class to be used for the color scale

  • color_limits (list, optional) – The minimum and maximum values for the color scale. If not provided, the minimum and maximum values of values will be used.

Returns:

colors – The color for each class in RGBA format.

Return type:

numpy.ndarray (n_classes, 4)

sqfa.plot.colors.get_normalized_color_map(color_map, values, color_limits=None)

Get the color map and normalizer for the given values.

Parameters:
  • color_map (str or matplotlib.colors.Colormap) – The colormap to use.

  • values (list or numpy.ndarray or torch.Tensor) – The value of each class to be used for the color scale

  • color_limits (list, optional) – The minimum and maximum values for the color scale. If not provided, the minimum and maximum values of values will be used.

Returns:

  • color_map (matplotlib.colors.Colormap) – The colormap to use.

  • color_normalizer (matplotlib.colors.Normalize) – The normalizer for the colormap.