DEV Community

Dhairya Shah
Dhairya Shah

Posted on

How to plot graphs in Python using Matplotlib

Hello, I am back with another article on Graphs in Python.

To plot graphs we will be using two python libraries

  • matplotlivb
  • numpy

Let's go on to code,

  • Importing libraries
import matplotlib.pyplot as plt
import numpy as np
Enter fullscreen mode Exit fullscreen mode
  • Entering values plotted on the graph
x = np.array([200, 400])
y = np.array([0, 100])
Enter fullscreen mode Exit fullscreen mode
  • Plotting them
plt.plot(x, y)
Enter fullscreen mode Exit fullscreen mode
  • Displaying Graph
plt.show()
Enter fullscreen mode Exit fullscreen mode

Make sure to check out the video

Top comments (0)