Create a Sine and Cosine Graph using Matplotlin in Python


In this tutorial, you will learn to create a sine and cosine graph using matplotlib in pyhton. Before you start, you need to import matplotlib and numpy first. The code to import is show below.

import matplotlib.pyplot as plt
import numpy as np

The source code to show sine and cosine graph below.

x = np.arange(0,10,0.2)
y = np.sin(x)
z = np.cos(x)
plt.title('Sine and Cosine Graph')

The result will be:

Back To Top