Python Data visualization--matplotlib user manual Getting Started: Pyplot drawing

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.