WrightTools.artists.plot_colorbar

WrightTools.artists.plot_colorbar(cax=None, cmap='default', ticks=None, clim=None, vlim=None, label=None, tick_fontsize=14, label_fontsize=18, decimals=None, orientation='vertical', ticklocation='auto', extend='neither', extendfrac=None, extendrect=False)[source]

Easily add a colormap to an axis.

Parameters:
  • cax (matplotlib axis (optional)) – The axis to plot the colorbar on. Finds the current axis if none is given.

  • cmap (string or LinearSegmentedColormap (optional)) – The colormap to fill the colorbar with. Strings map as keys to the WrightTools colormaps dictionary. Default is default.

  • ticks (1D array-like (optional)) – Ticks. Default is None.

  • clim (two element list (optional, deprecated)) – The true limits of the colorbar, in the same units as ticks. If None, streaches the colorbar over the limits of ticks. Default is None. Deprecated: Use vlim directly instead.

  • vlim (two element list-like (optional)) – The limits of the displayed colorbar, in the same units as ticks. If None, displays over clim. Default is None.

  • label (str (optional)) – Label. Default is None.

  • tick_fontsize (number (optional)) – Fontsize. Default is 14.

  • label_fontsize (number (optional)) – Label fontsize. Default is 18.

  • decimals (integer (optional)) – Number of decimals to appear in tick labels. Default is None (best guess).

  • orientation ({'vertical', 'horizontal'} (optional)) – Colorbar orientation. Default is vertical.

  • ticklocation ({'auto', 'left', 'right', 'top', 'bottom'} (optional)) – Tick location. Default is auto.

  • extend ({'neither', 'both', 'min', 'max'} (optional)) – If not ‘neither’, make pointed end(s) for out-of- range values. These are set for a given colormap using the colormap set_under and set_over methods.

  • extendfrac ({None, 'auto', length, lengths} (optional)) – If set to None, both the minimum and maximum triangular colorbar extensions have a length of 5% of the interior colorbar length (this is the default setting). If set to ‘auto’, makes the triangular colorbar extensions the same lengths as the interior boxes (when spacing is set to ‘uniform’) or the same lengths as the respective adjacent interior boxes (when spacing is set to ‘proportional’). If a scalar, indicates the length of both the minimum and maximum triangular colorbar extensions as a fraction of the interior colorbar length. A two-element sequence of fractions may also be given, indicating the lengths of the minimum and maximum colorbar extensions respectively as a fraction of the interior colorbar length.

  • extendrect (bool (optional)) – If False the minimum and maximum colorbar extensions will be triangular (the default). If True the extensions will be rectangular.

Returns:

The created colorbar.

Return type:

matplotlib.colorbar.ColorbarBase object