Python-matplotlib Foundation

Source: Internet
Author: User
Tags arithmetic

The Pyplot module in common matplotlib

Creating a normal linear graph can be as follows:

1 Import NumPy as NP 2 Import Matplotlib.pyplot as Plt 3 x = Np.linspace ( -1,1,50)4 y = 2*x+15plt.plot (x, y)6 Plt.show ()

Using Plt.show () in the script, the above figure will be out

In NumPy

Arange () is similar to the built-in function range (), which creates a one-dimensional array representing the arithmetic progression by specifying a start value, a final value, and a step size , noting that the resulting array does not contain a final value.

Linspace () creates a one-dimensional array that represents the arithmetic progression by specifying the start value, the final value , and the number of elements, and you can specify whether the final value is included by the endpoint parameter, and the default value is True, which contains the final value.

  

There are two lines in a picture
1 ImportNumPy as NP2 ImportMatplotlib.pyplot as Plt3x = Np.linspace ( -3,3,50)4Y1 = x**25y2 = 2*x+16Plt.figure (num=3,figsize= (8,5)) #num是图片名字, figsize picture length width 7 Plt.plot (x,y1)8Plt.plot (x,y2,color='Red', linewidth=1.0,linestyle='--') #linewidth表示宽度, LineStyle represents the type 9Plt.show ()

   

Get results:

  

Python-matplotlib Foundation

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.