gsplot.plot.scatter#

Functions

scatter(ax, x, y[, color, size, alpha])

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 or None, optional) – Color of the points. If None, a default color from the axis’s cycle is used (default is None).

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

  • alpha (int or float, 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:

matplotlib.collections.PathCollection

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>