sciris.sc_colors

Handle colors and colormaps.

Highlights:
  • Adds colormaps including 'turbo', 'parula', and 'orangeblue'

  • hex2rgb()/rgb2hex(): convert between different color conventions

  • vectocolor(): map a list of sequential values onto a list of colors

  • gridcolors(): map a list of qualitative categories onto a list of colors

Functions

alpinecolormap

This function generates a map based on ascending height.

arraycolors

Map an N-dimensional array of values onto the current colormap.

bandedcolormap

Map colors onto bands of hue and saturation, with lightness mapped linearly.

bicolormap

This function generators a two-color map, blue for negative, red for positive changes, with grey in the middle.

colormapdemo

Demonstrate a color map using simulated elevation data, shown in both 2D and 3D.

gridcolors

Create a qualitative "color map" by assigning points according to the maximum pairwise distance in the color cube.

hex2rgb

A little helper function to convert e.g.

hsv2rgb

Shortcut to Matplotlib's hsv_to_rgb method, accepts a color triplet or a list/array of color triplets.

midpointnorm

Alias to Matplotlib's TwoSlopeNorm.

orangebluecolormap

Create an orange-blue colormap; most like RdYlBu but more pleasing.

parulacolormap

Create a map similar to Viridis, but brighter.

rgb2hex

A little helper function to convert e.g.

rgb2hsv

Shortcut to Matplotlib's rgb_to_hsv method, accepts a color triplet or a list/array of color triplets.

sanitizecolor

Alias to matplotlib.colors.to_rgb, but also handles numeric inputs.

shifthue

Shift the hue of the colors being fed in.

turbocolormap

NOTE: as of Matplotlib 3.4.0, this colormap is included by default, and will soon be removed from Sciris.

vectocolor

This function converts a vector (i.e., 1D array) of N values into an Nx3 matrix of color values according to the current colormap.