gsplot.style.legend_colormap#

Functions

legend_colormap(ax[,Β cmap,Β label,Β ...])

Create and display a colormap legend on a specified axis.

legend_colormap(ax, cmap='viridis', label=None, num_stripes=8, vmin=0, vmax=1, reverse=False, **kwargs)[source]#

Create and display a colormap legend on a specified axis.

Parameters:
  • ax (Axes) – The target axis for the legend.

  • cmap (str, optional) – The colormap to use for the legend (default is β€˜viridis’).

  • label (str | None, optional) – The label to display for the colormap in the legend (default is None).

  • num_stripes (int, optional) – The number of stripes to divide the colormap into (default is 8).

  • vmin (int | float, optional) – The minimum value of the colormap (default is 0).

  • vmax (int | float, optional) – The maximum value of the colormap (default is 1).

  • reverse (bool, optional) – Whether to reverse the colormap (default is False).

  • **kwargs (Any) – Additional keyword arguments for configuring the legend.

Returns:

The created legend object.

Return type:

matplotlib.legend.Legend

Notes

This function binds passed parameters and creates a LegendColormap instance to generate a colormap legend on the specified axis.

Examples

>>> import gsplot as gs
>>> gs.legend_colormap(
...     ax=ax,
...     cmap="plasma",
...     label="Example Legend",
...     num_stripes=10,
...     vmin=0,
...     vmax=100,
...     reverse=True,
... )