gsplot.plot.scatter_colormap#
Functions
|
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
orfloat
, optional) – Size of the scatter points (default is 1).cmap (
str
, optional) – The name of the colormap to use (default is “viridis”).vmin (
int
orfloat
, optional) – The minimum value of the colormap scale (default is 0).vmax (
int
orfloat
, optional) – The maximum value of the colormap scale (default is 1).alpha (
int
orfloat
, optional) – Opacity of the scatter points (default is 1).label (
str
orNone
, 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:
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>