15 Feb Matplotlib – Line Graph
To draw a line graph in Matplotlib, use the plot() method. By default, plot() creates a line. The points used are the x and y coordinates of a line. Let us see an example wherein we will plot the x and y points:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
import matplotlib.pyplot as plt import numpy as np # Data to plot a line xPts = np.array([1, 9]) yPts = np.array([4, 12]) # Plot a line graph using the pyplot.plot() method # The two parameters are x and y axis plt.plot(xPts, yPts) # Display the figure plt.show() |
Output
If you liked the tutorial, spread the word and share the link and our website Studyopedia with others.
For Videos, Join Our YouTube Channel: Join Now
No Comments