gsplot.plot.scatter#
Functions
|
Creates a scatter plot on the specified axis. |
- scatter(ax, x, y, color=None, size=1, alpha=1, **kwargs)[source]#
Creates a scatter plot on the specified axis.
This function uses the Scatter class to generate a scatter plot with customizable size, color, and transparency.
- Parameters:
ax (
matplotlib.axes.Axes
) – The target axis for the scatter.x (
ArrayLike
) – The x-coordinates of the scatter points.y (
ArrayLike
) – The y-coordinates of the scatter points.color (
ColorType
orNone
, optional) – Color of the points. If None, a default color from the axis’s cycle is used (default is None).size (
int
orfloat
, optional) – Size of the scatter points (default is 1).alpha (
int
orfloat
, optional) – Opacity of the scatter points (default is 1).**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)
‘c’ (color)
- 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] >>> gs.scatter(ax=ax, x=x, y=y, color="red", size=20, alpha=0.8) <matplotlib.collections.PathCollection>