python matplotlib notes: scatter plot

1、参数
matplotlib.pyplot.scatter(x, y, s=None, c=None, marker=None, cmap=None, norm=None, vmin=None, vmax=None, alpha=None, linewidths=None, *, edgecolors=None, plotnonfinite=False, data=None, **kwargs)

x, y: float or array type, shape (n, ), place the data to be displayed;
s: float or array type, shape (n, ), optional, the default value is rcParams['lines.markersize'] * * 2. This parameter is the size of the point, which can be an integer or a floating point number;
c: represents the color of the point;

marker: represents the shape of a point, which can be a point, circle, or star;

alpha: represents the transparency of the point; the value range is 0-1;

cmap: represents a color mapping, used to map colors to points;

edgecolors: indicates the border color;

linewidth: indicates the width of the border;

label: represents the label of the data point;

2. Sample

import matplotlib.pyplot as plt

x = result.PREDICT
y = result.WIN_OR_NOT
fig=plt.figure(figsize = (10,6))

plt.scatter(x, y, 
           s=10,
           color='b',
           label="girls")

plt.xlabel('PREDICT')
plt.ylabel('WIN_OR_NOT')
plt.title('scatter plot')
#添加图例
plt.legend()
plt.show()

Insert image description here

3. Reference documents

matplotlib official website

Guess you like

Origin blog.csdn.net/weixin_39747882/article/details/128436678