monet.plots.colorbar_index

monet.plots.colorbar_index(ncolors, cmap, minval=None, maxval=None, dtype='int', basemap=None)

Create a colorbar with discrete colors and custom tick labels.

Parameters:
  • ncolors (int) – Number of discrete colors to use in the colorbar.

  • cmap (str or matplotlib.colors.Colormap) – Colormap to discretize and use for the colorbar.

  • minval (float, optional) – Minimum value for the colorbar tick labels. If None and maxval is None, tick labels will range from 0 to ncolors. If None and maxval is provided, tick labels will range from 0 to maxval.

  • maxval (float, optional) – Maximum value for the colorbar tick labels. If None, tick labels will range from 0 or minval to ncolors.

  • dtype (str or type, default “int”) – Data type for tick label values (e.g., “int”, “float”).

  • basemap (matplotlib.mpl_toolkits.basemap.Basemap, optional) – Basemap instance to attach the colorbar to. If None, uses plt.colorbar.

Returns:

(colorbar, discretized_cmap) where: - colorbar is the matplotlib.colorbar.Colorbar instance - discretized_cmap is the discretized colormap

Return type:

tuple