Featured image of post How to Draw Graphs with Python and matplotlib [Google Colab Compatible]

How to Draw Graphs with Python and matplotlib [Google Colab Compatible]

Explains the steps for beginners to easily draw and display sine and cosine wave graphs using Python's matplotlib.pyplot library with Google Colaboratory. You can try it immediately without any environment setup.

img_1.png

Requirements

  • Google Account

Steps

  1. Access https://colab.research.google.com/
  2. Select “File” -> “New notebook”
  3. Paste and run the following code
1
2
3
4
5
6
7
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 2*np.pi, 500)
plt.plot(x, np.sin(x), label="sin curve")
plt.plot(x, np.cos(x), label="cos curve")
plt.legend() # Show legend
plt.show()

Execution Result

img.png

References