50, matplotlib Picture Illustration example

Source: Internet
Author: User

1. appeased diagram

ImportMatplotlib.pyplot as Plt>>> labels ='Frogs','Hogs','Dogs','logs'>>> sizes = 15,20,45,10>>> Colors ='Yellowgreen','Gold','Lightskyblue','lightcoral'>>> explode = 0,0.1, 0,0>>>plt.pie (sizes,explode=explode,labels=labels,colors=colors,autopct='%1.1f%%', shadow=true,startangle=50)>>> Plt.axis ('Equal')(-1.2182175697473243, 1.11360285857795,-1.1087559272917165, 1.1164320127364205)>>> Plt.show ()

Determining the Coordinate range
>>>ImportNumPy as NP>>>ImportMatplotlib.pyplot as Plt>>> fromPylabImport*>>> x = Np.arange ( -5.0,5.0,0.02)>>> y1 =np.sin (x)>>> Plt.figure (1)<matplotlib.figure.figure object at 0x000002364f153128>>>> Plt.subplot (211)<matplotlib.axes._subplots. Axessubplot Object at 0x000002364b86ce80>>>>Plt.plot (x,y1) [<matplotlib.lines.line2d Object at 0x000002365002db00>]>>> Plt.subplot (212)<matplotlib.axes._subplots. Axessubplot object at 0x000002364d73c320>>>> Xlim ( -2.5,2.5)(-2.5, 2.5)>>> Ylim ( -1,1)(-1, 1)>>>Plt.plot (x,y1) [<matplotlib.lines.line2d Object at 0x000002364d839f28>]>>> Plt.show ()

Overlay chart
Import NumPy as NP Import Matplotlib.pyplot as plt>>> t = np.arange (0.,5.,0.2)>>> plt.plot (t,t,' r-- ', t,t**2,'bs', t,t**3,'g') [ <matplotlib.lines.line2d object at 0x00000236519f9710>, <matplotlib.lines.line2d object at 0x00000236519f99b0>, <matplotlib.lines.line2d object at 0x0000023651a00240>]>>> Plt.show ()

Plt.figure ()
>>>ImportMatplotlib.pyplot as Plt>>> Plt.figure (1)<matplotlib.figure.figure object at 0x0000023650018ba8>>>> Plt.subplot (211)<matplotlib.axes._subplots. Axessubplot object at 0x0000023650018ef0>>>> plt.plot ([a])[<matplotlib.lines.line2d Object at 0x00000236536810f0>]>>> Plt.subplot (212)<matplotlib.axes._subplots. Axessubplot object at 0x000002364cfc1278>>>> plt.plot ([4,5,6])[<matplotlib.lines.line2d Object at 0x00000236536fa208>]>>> Plt.figure (2)<matplotlib.figure.figure object at 0x00000236536c4128>>>> plt.plot ([4,5,6])[<matplotlib.lines.line2d Object at 0x0000023653748588>]>>> Plt.figure (1)<matplotlib.figure.figure object at 0x0000023650018ba8>>>> Plt.subplot (211)<matplotlib.axes._subplots. Axessubplot object at 0x0000023650018ef0>>>> plt.title (' Easy AS')<matplotlib.text.text object at 0x0000023653660278>>>> plt.show ()

Plt.text () Add text description
>>>ImportNumPy as NP>>>ImportMatplotlib.pyplot as Plt>>> mu,sigms =100,15>>> mu,sigma = 100,15>>> x = mu+sigma * NP.RANDOM.RANDN (10000)>>> n,bins,patches = plt.hist (x,50,normed=1,facecolor='g', alpha=0.75)>>> Plt.xlabel ('Smarts')<matplotlib.text.text object at 0x000002365371b748>>>> Plt.ylabel ('probability')<matplotlib.text.text object at 0x00000236536c4d30>>>> plt.title ('Histogram of IQ')<matplotlib.text.text object at 0x00000236519cc0f0>>>> plt.text (60,0.25,r'$\mu=100,\ \sigma=15$')<matplotlib.text.text object at 0x0000023651a1a0b8>>>> plt.axis ([40,160,0,0.03])[40, 160, 0, 0.03]>>> Plt.show ()

50, matplotlib Picture Illustration example

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.