scientimate.gencolormap#

cmap_ncolor, cmap_ncolor_plt = scientimate.gencolormap(cmapcolors=[[255,255,255],[0,0,0]], ncolor=256, dispout='no')

Description#

Generate a colormap from input colors

Inputs#

cmapcolors=[[255,255,255],[0,0,0]]
Colors that are used to generate colormap
Colors should be defined as [M*3] array in RGB color format
At least two colors should be defined, i.e. M should be equal or larger than 2
All values should be between 0 and 255
Any available colormap name such as ‘cool’, ‘winter’, etc also can be used
ncolor=256

Number of colors in generated colormap

dispout=’no’

Define to display outputs or not (‘yes’: display, ‘no’: not display)

Outputs#

cmap_ncolor
Colormap with ncolor number of colors in RGB color format between 0 and 1
To convert 0-1 scale to 0-255 scale, multiply cmap_ncolor values by 255
cmap_ncolor_plt

Colormap with ncolor number of colors in Matplotlib format

Examples#

import scientimate as sm

#Blue-Red
cmap_ncolor,cmap_ncolor_plt=sm.gencolormap([[41, 128, 185],[192, 57, 43]],256,'yes')

#Blue-White-Red
cmap_ncolor,cmap_ncolor_plt=sm.gencolormap([[41, 128, 185],[255,255,255],[192, 57, 43]],256,'yes')

#Blue-White-Green
cmap_ncolor,cmap_ncolor_plt=sm.gencolormap([[33, 150, 243],[255,255,255],[76, 175, 80]],256,'yes')

#Red-Brown sequential
cmapcolors=[[192,57,43],[155,89,182],[41,128,185],[39,174,96],[241,196,15],[211,84,0]]
cmap_ncolor,cmap_ncolor_plt=sm.gencolormap(cmapcolors,10,'yes')

#cool colormap
cmap_ncolor,cmap_ncolor_plt=sm.gencolormap('cool',256,'yes')

References#

Colormap

Color