sciris.sc_colors.vectocolor

vectocolor(vector, cmap=None, asarray=True, reverse=False, minval=None, maxval=None, midpoint=None)[source]

This function converts a vector (i.e., 1D array) of N values into an Nx3 matrix of color values according to the current colormap. It automatically scales the vector to provide maximum dynamic range for the color map.

Note: see sc.arraycolors() for multidimensional input.

Parameters
  • vector (array) – Input vector (or list, it’s converted to an array)

  • cmap (str) – is the colormap (default: current)

  • asarray (bool) – whether to return as an array (otherwise, a list of tuples)

  • reverse (bool) – whether to reverse the list of colors

  • minval (float) – the minimum value to use

  • maxval (float) – the maximum value to use

  • midpoint (float) – the midpoint value to use

Returns

Nx4 array of RGB-alpha color values

Return type

colors (array)

Example:

n = 1000
x = randn(n,1);
y = randn(n,1);
c = sc.vectocolor(y);
pl.scatter(x, y, c=c, s=50)

New in version 1.2.0: midpoint argument.