Plot a graph using Python graph plot the graph of f(x) =sin(x) in range [-2*pi, 2*pi]
Plot the graph of f(x) =sin(x) in range [-2*pi, 2*pi]
In this program we are polt a graph using python
The Program is divide into 3 step
Step1:-- import python package using
from pylab import *
import numpy as np
Step2 :- assign the value of x and function
x = np.linspace(-2*np.pi, 2 * np.pi, 200)
f = np.sin(x)
Step3 :- Plot the graph and show it using plot() , show() function
# plot the graph
plot(x, f)
# show output/ graph
show()
Complete program
# plot the graph of f(x) =sin(x) in range [-2*pi, 2*pi]
from pylab import *
import numpy as np
# x = np.linspace(-2*pi, 2 * pi, 200)
x = np.linspace(-2*np.pi, 2 * np.pi, 200)
f = np.sin(x)
plot(x, f)
show()
Output
0 Comments