Reference Matplotlib Official Guide:
Https://matplotlib.org/tutorials/introductory/pyplot.html#sphx-glr-tutorials-introductory-pyplot-py
Pyplot is a commonly used drawing module with very powerful functions. , let's see what it's capable of.
1. Quickly draw common graphics
2. Using the keyword string to draw
3. Use category variables to paint
4. Create Multi-image
1 ImportMatplotlib.pyplot as Plt2%Matplotlib Inline3Plt.figure (1)# the first figure4Plt.subplot (211)#The first subplot in the first figure5Plt.plot ([1, 2, 3])6Plt.subplot (212)#The second subplot in the first figure7Plt.plot ([4, 5, 6])8 9 TenPlt.figure (2)#a second figure OnePlt.plot ([4, 5, 6])#creates a subplot (111) by default A -Plt.figure (1)#Figure 1 Current, subplot (212) still current -Plt.subplot (211)#Make subplot (211) in Figure1 current thePlt.title ('Easy as 1, 2, 3')#Subplot 211 Title
1 ImportMatplotlib.pyplot as Plt2 ImportNumPy as NP3 4Np.random.seed (19680801)5data = NP.RANDOM.RANDN (2, 100)6 7Fig, AXS = Plt.subplots (2, 2, figsize= (5, 5))8 axs[0, 0].hist (data[0])9Axs[1, 0].scatter (data[0], data[1])TenAxs[0, 1].plot (data[0], data[1]) OneAxs[1, 1].HIST2D (data[0], data[1]) A -Plt.show ()
5. Add Text: Axis label, property label
1 ImportMatplotlib.pyplot as Plt2 ImportNumPy as NP3Mu, sigma = 100, 154x = mu + sigma * NP.RANDOM.RANDN (10000)5 6 #The histogram of the data7N, bins, patches = plt.hist (x, Normed=true, facecolor='g', alpha=0.75)8 9 TenPlt.xlabel ('Smarts') OnePlt.ylabel ('probability') APlt.title ('Histogram of IQ') -Plt.text (. 025, R'$\mu=100,\ \sigma=15$')#Support Latex Format -Plt.axis ([40, 160, 0, 0.03]) the Plt.grid (True) -Plt.show ()
Python Data visualization--matplotlib user manual Getting Started: Pyplot drawing