Examples of integration of Python function drawing and advanced algebra (2): Flashpoint function
1: Set X|Y axis text label
import numpy as np
import matplotlib.pyplot as plt
from pylab import mpl
'''
Function: Set the label text of the X|Y axis
Call function: plt.xlabel(string); plt.ylabel(string)
Parameter Description:
string: the text of the label
'''
#Set Chinese display font
mpl.rcParams["font.sans-serif"] = ["SimHei"]
#Set normal display symbols
mpl.rcParams["axes.unicode_minus"] = False
x = np.linspace(0.05, 10, 1000)
y = np.sin(x)
plt.plot(x, y, "-.", lw=2, c="c", label="X|Y axis setting label text")
plt.legend()
plt.xlabel("X-axis coordinate axis")
plt.ylabel("Y-axis coordinate axis")
plt.show()
2: Set the X|Y axis text label running effect
Three: Add grid ticks and colors to the graph
import numpy as np
import matplotlib.pyplot as plt
from pylab import mpl
'''
Line number function: Draw grid lines of tick marks
Calling function signature: plt.grid(linestyle=":",color="g")
Parameter Description:
linestyle: Line style of grid lines
color: The line color of the grid lines
'''
#Set Chinese display font
mpl.rcParams["font.sans-serif"] = ["SimHei"]
#Set normal display symbols
mpl.rcParams["axes.unicode_minus"] = False
x = np.linspace(0.05, 10, 1000)
y = np.sin(x)
plt.plot(x, y, ls="-.", lw=2, c="c", label="Grid grid function creates grid background and polyline color")
plt.legend()
plt.xlabel("X-axis coordinate axis")
plt.ylabel("Y-axis coordinate axis")
plt.grid(linestyle=":", color="r")
plt.show()