Explanation
In this example,
- we first generate 100 evenly spaced x values between 0 and 2π using the
linspace function from NumPy. - Then we calculate the y values for the sine function using NumPy’s
sin function. - Next, we use Matplotlib’s
plot function to create a line plot of the sine function. - We then add a title and axis labels using the
title, xlabel, and ylabel functions. Finally, we display the plot using the show function.
To Generate Other Plots (cos, tan etc.)
You can modify this example to plot other trigonometric functions such as cosine or tangent by replacing the np.sin function with np.cos or np.tan, respectively.