gsplot.plot.scatter_colormap#

Functions

scatter_colormap(ax, x, y, cmapdata[, size, ...])

Creates a scatter plot with colormap-based coloring on the specified axis.

scatter_colormap(ax, x, y, cmapdata, size=1, cmap='viridis', vmin=0, vmax=1, alpha=1, label=None, **kwargs)[source]#

Creates a scatter plot with colormap-based coloring on the specified axis.

This function uses the ScatterColormap class to generate a scatter plot with customizable size, colormap, and transparency.

Parameters:
  • ax (matplotlib.axes.Axes) – The target axis for the scatter plot.

  • x (ArrayLike) – The x-coordinates of the scatter points.

  • y (ArrayLike) – The y-coordinates of the scatter points.

  • cmapdata (ArrayLike) – The data used to determine the color of the scatter points.

  • size (int or float, optional) – Size of the scatter points (default is 1).

  • cmap (str, optional) – The name of the colormap to use (default is “viridis”).

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

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

  • alpha (int or float, optional) – Opacity of the scatter points (default is 1).

  • label (str or None, optional) – Label for the colormap, used in legends (default is None).

  • **kwargs (Any) – Additional keyword arguments passed to the scatter method of Matplotlib’s Axes.

Notes

  • This function utilizes the ParamsGetter to retrieve bound parameters and the CreateClassParams class to handle the merging of default, configuration, and passed parameters.

  • Alias validation is performed using the AliasValidator class.

    • ‘s’ (size)

Returns:

The scatter plot as a PathCollection object.

Return type:

matplotlib.collections.PathCollection

Examples

>>> import gsplot as gs
>>> x = [1, 2, 3, 4]
>>> y = [10, 20, 15, 25]
>>> cmapdata = [0.1, 0.5, 0.3, 0.9]
>>> gs.scatter_colormap(ax=ax, x=x, y=y, cmapdata=cmapdata, cmap="plasma", label="Data")
<matplotlib.collections.PathCollection>