API References
Python package colourmap generates an N unique colors from the specified input colormap.
- colourmap.colourmap.fromlist(y, cmap='Set1', gradient=None, method='matplotlib', scheme='rgb', verbose=3)
Generate colors from input list.
Description
This function creates unique colors based on the input list y and the cmap. When the gradient hex color is defined, such as ‘#000000’, a gradient coloring space is created between two colors.
The start color of the particular y, using the cmap and The end color is the defined gradient, such as ‘#000000’.
- param y
For each unique value, a unique color is given back.
- type y
list of strings or integers
- param cmap
Colormap. The default is ‘Set1’.
- type cmap
String, optional
- param gradient
Hex end color for the gradient. ‘#FFFFFF’
- type gradient
String, (default: None)
- param method
Method to generate colors ‘matplotlib’ (default) ‘seaborn’
- type method
String, optional
- param scheme
The output of color is in the scheme: ‘rgb’ ‘hex’
- type scheme
String, optional
- param verbose
Print progress to screen. The default is 3. 0: None, 1: ERROR, 2: WARN, 3: INFO (default), 4: DEBUG, 5: TRACE
- type verbose
int, optional
- returns
List of colors in the same order as y. dict for the unique colors
- rtype
tuple containing
References
- colourmap.colourmap.generate(N, cmap='Set1', method='matplotlib', keep_alpha=False, scheme='rgb', verbose=3)
Generate N RGB colors for cmap.
- Parameters
N (Integer) – Number of colors to be generated.
cmap (String, optional) – ‘Set1’ (default) ‘Set2’ ‘rainbow’ ‘bwr’ Blue-white-red ‘binary’ or ‘binary_r’ ‘seismic’ Blue-white-red ‘Blues’ white-to-blue ‘Reds’ white-to-red ‘Pastel1’ Discrete colors ‘Paired’ Discrete colors ‘Set1’ Discrete colors
method (String, optional) – Method to generate colors ‘matplotlib’ (default) ‘seaborn’
scheme (String, optional) – The output of color is in the scheme: ‘rgb’ ‘hex’
verbose (int, optional) – Print progress to screen. The default is 3. 0: None, 1: ERROR, 2: WARN, 3: INFO (default), 4: DEBUG, 5: TRACE
References
Colormap: https://matplotlib.org/examples/color/colormaps_reference.html
- Returns
color_list
- Return type
numpy array with colors that range between [0-1, 0-1, 0-1].
- colourmap.colourmap.hex2rgb(colors)
Convert hex color-range to RGB.
- Parameters
colors (list) – list of str.
- Return type
list of rgb colors.
- colourmap.colourmap.hex2rgba(colors)
Convert hex color-range to RGBA.
- Parameters
colors (list) – list of str.
- Return type
list of rgb colors.
- colourmap.colourmap.linear_gradient(start_hex, finish_hex='#FFFFFF', n=10)
Return a gradient list of (n) colors between two hex colors.
Description
start_hex and finish_hex should be the full six-digit color string, inlcuding the number sign (“#FFFFFF”)
- param start_hex
Hex starting color.
- type start_hex
str
- param finish_hex
Hex end color. The default is “#FFFFFF”.
- type finish_hex
str, optional
- param n
Spacing between start-stop colors.
- type n
int, (default: 10)
- returns
lineair spacing.
- rtype
dict
- colourmap.colourmap.rgb2hex(colors, keep_alpha=False)
Convert RGB color-range to hex.
- Parameters
colors (list) – list of floats that range between [0-1, 0-1, 0-1].
keep_alpha (bool, optional) – Keep the alpha value, which is the first number in RGB range. The default is False.
- Return type
list of hex colors.