Example of integration of Python function drawing and advanced algebra (2): Scatter function


Examples of integration of Python function drawing and advanced algebra (1): sine function and cosine function

Example of integration of Python function drawing and advanced algebra (2): Scatter function

Example of integration of Python function drawing and advanced algebra (3): setting X|Y axis|grid lines

Example of integration of Python function drawing and advanced algebra (4): Setting the X|Y axis reference line|reference area

Examples of integration of Python function drawing and advanced algebra (5): Comprehensive case of line graphs




1: Function plot(), showing the changing trend of variables

import numpy as np 
import matplotlib.pyplot as plt 
from pylab import mpl 

''' 
  Function function: Find the relationship between variables 
  Call signature: plt.scatter(x,y,c="b" label="scatter function, find variables Example of the relationship between "") 
  Parameter description: 
    x: value on the x axis 
    y: value on the y axis 
    c: color of the mark in the flash point diagram 
    label: label for marking the graphic content 
''' 
# Set the Chinese display font 
mpl .rcParams["font.sans-serif"] = ["SimHei"] 

# Set the normal display symbol 
mpl.rcParams["axes.unicode_minus"] = False 
x = np.linspace(0.05, 10, 5000) 

y = np. random.rand(5000) 

plt.scatter(x, y, label="scatter function, find instances of relationships between variables") 

plt.legend() 

plt.show()

 2: The effect of plot function operation

Three: Set the X|Y axis value display range

import numpy as np 
import matplotlib.pyplot as plt 
from pylab import mpl 

''' 
  Function function: Set the x-axis value display range 
  Call signature: plt.xlim(xmin,xmax) 
  Parameter description: xmin: the minimum value 
     xmax 
     on the X-axis : The 
maximum 
     value 
on 
the ["SimHei"] 
# Set the normal display symbol 
mpl.rcParams["axes.unicode_minus"] = False 
x = np.linspace(0.05, 10, 1000) 
# Note: The random numbers taken for the x-axis and y-axis must be consistent, otherwise Error 
y = np.random.rand(1000) 
plt.scatter(x, y, label="xlim() function sets the numerical display range of the X-axis") 
plt.legend() 
# Set the X-axis value range 
plt.xlim (0.05, 20) 
# Set the value range of the Y axis 
plt.ylim(0,3)
plt.show()





Four: Set the X|Y axis value range effect

 

Guess you like

Origin blog.csdn.net/u014635374/article/details/133165922