mapclassify.util.get_color_array

mapclassify.util.get_color_array(values, scheme='quantiles', cmap='viridis', alpha=1, nan_color=[255, 255, 255, 255], as_hex=False, **kwargs)[source]

Convert array of values into RGBA or hex colors using a colormap and classifier. This function is useful for visualization libraries that require users to provide an array of colors for each object (like pydeck or lonboard) but can also be used to create a manual column of colors passed to matplotlib.

Parameters:
valueslist-like

array of input values

schemestr, optional

string description of a mapclassify classifier, by default “quantiles”

cmapstr, optional

name of matplotlib colormap to use, by default “viridis”

alphafloat

alpha parameter that defines transparency. Should be in the range [0,1]

nan_colorlist, optional

RGBA color to fill NaN values, by default [255, 255, 255, 255]

as_hex: bool, optional

if True, return a (n,1)-dimensional array of hexcolors instead of a (n,4) dimensional array of RGBA values.

kwargsdict

additional keyword arguments are passed to mapclassify.classify

Returns:
numpy.array

numpy array (aligned with the input array) defining a color for each row. If as_hex is False, the array is \((n,4)\) holding an array of RGBA values in each row. If as_hex is True, the array is \((n,1)\) holding a hexcolor in each row.