lgca.plots.colorbar_index

lgca.plots.colorbar_index(ncolors, cmap, use_gridspec=False, cax=None)

Create a colorbar with ncolors colors.

Builds a discrete colormap with ncolors colors from the near-continuous colormap cmap, adds it to the axis cax and draws tick labels in the center of each color. If ncolors is high, tick positions are determined automatically using MaxNLocator and labels are formatted with FuncFormatter.

Parameters:
  • ncolors (int) – Desired number of colors for the discretized colormap.

  • cmap (str or matplotlib.colors.Colormap) – Near-continuous colormap to create discrete colormap from, e.g. matplotlib.cm.jet or 'jet'.

  • use_gridspec (bool) – Passed on to matplotlib.pyplot.colorbar().

  • cax (matplotlib.axes.Axes object, optional) – Axis into which the colorbar will be drawn.

Returns:

Colorbar instance.