Python matplotlib draws scatter plots with pyplot

Example of pyplot scatter plot:

import matplotlib.pyplot as plt
import numpy as np
import math
import random
plt.rcParams['font.sans-serif']=['SimHei']#used to display chinese labels normally 
plt.rcParams['axes.unicode_minus']=False#used to display negative signs normally 
if __name__== '__main__':
X = np.linspace(0, 20, 500)
Y1 = [math.sin(x) + (random.random() - 0.5) / 2 for x in X]
Y2 = [math.cos(x) + (random.random() - 0.5) / 2 for x in X]
#scatter plot 
plt.scatter(X, Y1, s=10, c="red", marker=".", alpha=1)
plt.scatter(X, Y2, s=20, c="blue", marker="^", alpha=0.3, linewidths=1)
plt.xlabel("x axis")
plt.ylabel(("y axis"))
plt.title("this is the title")
plt.show()

Parameter Explanation

s: The width size of the point, the larger the number, the larger the point. The width of different points can be set by passing in an array.

Mark: The shape of the point, refer to the following image.

Alpha: Transparency, between 0 and 1
Linewidths: Line width is actually the width of the outer contour of a point, not the width of the contour line.

Author: Lan Hezhong

Email: Lanhezhong; 163. com