In this blog, I will show you how to create a simple plot in Matplotlib.
Plot
Matplotlib has provided a method called plot
from pyplot
. This method requires two arguments, which are the collection of x-points and y-points respectively. Let me show you how to use it.
First of all, you have to import the required packages
import matplotlib.pyplot as plt
import numpy as np
Next, create two arrays that define the points in the x and y coordinates
xpoints = np.array([0, 6])
ypoints = np.array([0, 255])
I have defined two points from the above code: (0, 0) and (6, 255).
Then, plot xpoints
and ypoints
into the Matplotlib
plt.plot(xpoints, ypoints)
plt.show()
The above code will show the following output
Congratulations, you have just created a plot in Matplotlib. Thank you for reading this blog, and have a great day!
Top comments (0)