The Pyplot module in common matplotlib
Creating a normal linear graph can be as follows:
1 Import NumPy as NP 2 Import Matplotlib.pyplot as Plt 3 x = Np.linspace ( -1,1,50)4 y = 2*x+15plt.plot (x, y)6 Plt.show ()
Using Plt.show () in the script, the above figure will be out
In NumPy
Arange () is similar to the built-in function range (), which creates a one-dimensional array representing the arithmetic progression by specifying a start value, a final value, and a step size , noting that the resulting array does not contain a final value.
Linspace () creates a one-dimensional array that represents the arithmetic progression by specifying the start value, the final value , and the number of elements, and you can specify whether the final value is included by the endpoint parameter, and the default value is True, which contains the final value.
There are two lines in a picture
1 ImportNumPy as NP2 ImportMatplotlib.pyplot as Plt3x = Np.linspace ( -3,3,50)4Y1 = x**25y2 = 2*x+16Plt.figure (num=3,figsize= (8,5)) #num是图片名字, figsize picture length width 7 Plt.plot (x,y1)8Plt.plot (x,y2,color='Red', linewidth=1.0,linestyle='--') #linewidth表示宽度, LineStyle represents the type 9Plt.show ()
Get results:
Python-matplotlib Foundation