dotools_py.utility.generate_cmap#
- dotools_py.utility.generate_cmap(*args)[source]#
Generate a custom colormap.
This functions returns a color map. Specify colors to set a gradient in the specified order. Use (1, 1, 1, 0) to set transparent
- Parameters:
- args
colors, RGB or HexaCodes.
- Return type:
- Returns:
custom colormap.
Example
import dotools_py as do import matplotlib.pyplot as plt import numpy as np cbar = do.utility.generate_cmap('royalblue', 'lightsteelblue', 'white', 'tomato', 'firebrick') plt.figure(figsize=(6, 2)) gradient = np.linspace(0, 1, 256).reshape(1, -1) gradient = np.vstack([gradient] * 10) # Stack to make it thicker plt.imshow(gradient, aspect='auto', cmap=cbar) plt.axis('off')