Featured image of post How to draw graphs using Python (matplotlib.pyplot)

How to draw graphs using Python (matplotlib.pyplot)

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

comments powered by Disqus