Fortune Telling Collection - Zodiac Guide - How does Python draw the diagram of cos and sin?
How does Python draw the diagram of cos and sin?
In python's own editor IDLE, create a new script, such as drawing. py。
Import the required modules.
Import numpy as np.
Import scipy as sp.
Import pylab as pl.
2
input code
x=np.linspace(0,4*np.pi, 100)
pl.plot(x,pl.sin(x))
pl.show()
three
Execute the code and press F5 to display the picture directly.
four
Some precautions:
1. Method Linspace (0,4 * np.pi, 100) refers to generating 100 points from 0 to 4*pi.
2. Method plot is a drawing function, which is equivalent to plot(x, y), where x is the abscissa and y is the ordinate.
3.show () is used to show.
Hope to adopt! !
- Related articles
- Download the complete txt works of the Patron Saint of the Chinese Zodiac.
- 92nd lunar month 165438+1October16 What is a constellation?
- 1988 lunar calendar 10 October 19 What is the constellation?
- What's the name of Yinglan, the heroine of East of Eden?
- How to draw the twelve constellations
- Which constellation has the most stars?
- The longest-lived constellation, see if there is you.
- What is the constellation of 20055 17 _ What is the constellation of 20050517?
- 1August, 998 10 A boy will not get married until he marries a girl born that year.
- Four sets of personal information of Wu Peng, the host of CCTV.