A simple application of the Python Visual extension module matplotlib

Source: Internet
Author: User
Tags cos sin

The expansion modules for Python scientific Computing and visualization include: NumPy, SciPy, SymPy, Matplotlib, Traits, Traitsui, Chaco, TVTK, Mayavi, Vpython, OpenCV.


The Matplotlib module relies on the NumPy module and the Tkinter module to draw various forms of graphics, including line graphs, histograms, pie charts, scatter plots, error bar graphs, and more.


Plotting a sinusoidal curve

>>> Import Numpyas NP

>>> Import Pylabas Pl

>>> t = np.arange (0.0, 2.0*np.pi, 0.01)

>>> s = np.sin (t)

>>> Pl.plot (t,s)

>>> Pl.xlabel (' x ')

>>> Pl.ylabel (' y ')

>>> pl.title (' sin ')

>>> Pl.plot (t,s)

>>> Pl.show ()

650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M01/06/78/wKiom1m4zbqjadZiAACE70pwGpQ062.jpg-wh_500x0-wm_ 3-wmp_4-s_2150569922.jpg "title=" Untitled 1.jpg "alt=" Wkiom1m4zbqjadziaace70pwgpq062.jpg-wh_50 "/>


Plot scatter plots

>>> a = Np.arange (0, 2.0*np.pi, 0.1)

>>> B = Np.cos (a)

>>> Pl.scatter (A, B)

>>> Pl.show ()

650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M01/A5/29/wKioL1m4zc6yl067AACjjqdY_no823.jpg-wh_500x0-wm_ 3-wmp_4-s_613188064.jpg "title=" Untitled 2.jpg "alt=" Wkiol1m4zc6yl067aacjjqdy_no823.jpg-wh_50 "/>


Plot scatter plots

>>> Import Matplotlib.pylabas Pl

>>> Import Numpyas NP

>>> x = np.random.random (100)

>>> y = np.random.random (100)

>>> pl.scatter (x,y,s=x*500,c=u ' R ', marker=u ' * ')

#s指大小, c refers to color, marker refers to the shape of the symbol

>>> Pl.show ()

650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M01/A5/29/wKioL1m4zd3jFJCVAADhlvX1WcA561.jpg-wh_500x0-wm_ 3-wmp_4-s_2629655330.jpg "title=" Untitled 3.jpg "alt=" Wkiol1m4zd3jfjcvaadhlvx1wca561.jpg-wh_50 "/>


Modify Scatter symbols

>>> a = Np.arange (0, 2.0*np.pi, 0.1)

>>> B = Np.cos (a)

>>> Pl.scatter (a,b,marker= ' + ')

>>> Pl.show ()

650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M01/06/78/wKiom1m4zhbgZbwsAACfaYCtU8A271.jpg-wh_500x0-wm_ 3-wmp_4-s_2707411492.jpg "title=" Untitled 4.jpg "alt=" Wkiom1m4zhbgzbwsaacfayctu8a271.jpg-wh_50 "/>


This article from the "CAS Computer Training" blog, declined to reprint!

A simple application of the Python Visual extension module matplotlib

Related Article

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.