1.
IMPORT NUMPY AS NPIMPORT MATPLOTLIB.PYPLOT AS PLTDEF F1 (t): #根据横坐标t, defines the ordinate return np.exp (-t) *np.cos (2*NP.PI*T) for the first curve def F2 (t): #根据横坐标t, defining the Ordinate return np.sin (2*np.pi*t) of the second curve * Np.cos (3*np.pi*t) #定义很坐标的值, from Np.arange (0.0,5.0,0.02), #. The list of arithmetic progression that represents 0--5 [0,0.02,0.04......4.8] does not include 5.0t = np.arange (0.0,5.0,0.02) #定义一个画布plt. Figure () # Parametric analysis: Plt.plot (axis value, ordinate value, "color", label,linewidth= in the legend built by Legend ()) #plt the. Plot () function, which automatically corresponds to the #label value of the nearest figure $...$ The formula between this page can be Http://www.codecogs.com/latex/eqneditor.phpplt.plot (T,F1 (t), "G", label= "$f (t) =e^{-t} \cdot \cos (2 \pi t) $ ") plt.plot (T,F2 (t)," R. ", label=" $g (t) =\sin (2 \PI T) \cos (3 \pi t) $ ", linewidth=2) #确定坐标轴的值, the label of the axis, and the title of the canvas Plt.axis ([0.0,5.01,-1.0,1.5]) Plt.xlabel ("T") Plt.ylabel ("V") plt.title ("A simple example") Plt.grid (True)   #生成网格plt. Legend () #产生右上角的图例 plt.show () # # #matplotlib. Pyplot in Add_subplot ( 2,3,2) function parameter, used to divide the canvas # # # #建立一个画布fig2, can be understood as the canvas object Fig2=plt.figure () #把fig2分为: 2 rows 1 columns, select the 1th block for use. Note: Add_subplot (,,) function is to have object, as used here Fig2ax=fig2.add_subplot (2,1,1) plt.plot (T,T/3, "R", label= "$11$", linewidth=3) Plt.legend () #把fig2分为: 2 rows and 2 columns, select 4th block for use. Ax=fig2.add_subplot (2,2,4) plt.plot (T,T/3, "B", label= "$11$") Plt.legend () plt.show ()
This article is from the "Joe Tech" blog, so be sure to keep this source http://joekeji.blog.51cto.com/12424130/1952134
Python with Matplotlib.pyplot drawing summary