To plot your data in form of points on matplotlib graph the plt.scatter() function is used. The plt.scatter() function requires two arguments i.e. the x and y coordinates of the data points you wish to plot. The full from of the matplotlib.pyplot.scatter() function is
As stated the x and y are mandatory and they are the x and y coordinates of the data points you wish to plot using the matplotlib pyplot scatter function. The size of the x list/array must be equal to the list/array. The other parameters are set by default and you do not need to define them. \newline
The s = None is he maker size in points**2 (typographic points are 1/72 in.). By setting to the None the default value is rcParams['lines.markersize']**2.\newline
The c = None are the marker colors. IF set to None in that case te marker color is determined by the value of color, facecolor,or facecolors.
The marker = None is the marker style. The marker can be either and instance of the class or the next shorthand for a particular marker. If set to None the default value is rcParams['scatter.marker'] or 'o'.
cmap=None - is the colormap instance or registered colormap name used to map scalar data to colors. This parameter is ignored if \(c\) is the RGBA.Since by default the cmap is set to None the colormap value is equal to rcParams['image.cmap'] or 'viridis'.
norm - this is short for normalization method which can be used to scale scalar data to the [0,1] range before mapping to colors using cmap.By default a linear scaling is used, mapping the lowest value to 0 and the highest to 1.
vmin, vmax = None - These set the minimum (vmin) and maximum (vmax) data values for the colormap scaling. By default these parameters are set to None so the minimum and maximum of the data are automatically taken. When using the colormap, vmin and vmax allow you to control the range of data values that the colormap covers.
alpha=None - this parameter controls the transparency level of points in the scatter plot. The value should be in 0 to 1 range where 0 is completely transparent and 1 is completely opaque. By default this parameter is equal to None which means that all points are fully opaque.
linewidths = None - this parameter controls the width of the edges around each scatter point. By default the value is None which means that default width is used. Larger values will make the edges thicker, while smaller values make them thinner.
edgecolors = None - is the parameter that specifies the edge color(s) of the edges around the scatter points. This can be a single coloror a sequence of colors. Common values include 'face' (same as the point's face color), 'none' (no edges), or any valid color format in Matplotlib.
plotnonfinite = False - the parameter determines whether to plot points that are not finite (like NaN or Inf). The default value is equal to False which means that non-finite points are not plotted. If the parameter is set to True, such points will appear in the plot.
data = None - the parameter allows passing a dictionary or a DataFrame that provides the data for the scatter plot. It can be used to reference column names directly, making it easier to manage data when working with Pandas or similar libraries.
**kwargs - This represents additional keyword arguments that can be passed to customize the scatter plot further, such as marker style, colors, labels, etc. Any valid Matplotlib property can be passed through **kwargs.
Example - First scatter plot
In this example we will crate the coordinates of data points in form of lists and use plt.scatter() function to plot this data points. The points are define in form of two lists x and y coordinates.
\begin{eqnarray}
x &=& [1,2,3,4,5]\\ \nonumber
y &=& [2,4,6,8,10]
\end{eqnarray}
The first step was to define required libraries. Since we do not need numpy i.e. both variables are defined using built-in python lists the only library that must be defined is the matplotlib with pyplot module.
import matplotlib.pyplot as plt
Next we are going to define the x and y variable.
x = [1,2,3,4,5]
y = [2,4,6,8,10]
The we will define the the figure size to 12 by 8 inches, call the scatter function and define the x and y arguments, define the title (scatter plot example) name the x and y axes using xlabel and ylabel commands, define the grid, and finally show the graph.