Mr. Asit wants to plot line graph. Help him to select the correct matplotlib function from the following.
Mr. Asit wants to plot line graph. Help him to select the correct matplotlib function from the following.
Solution
✅ Correct Option: 2
The plot() function of matplotlib.pyplot draws a line graph. After import matplotlib.pyplot as plt, it is called as plt.plot(x, y), and it joins the points with straight lines by default.
Option 3: plot.line() is a pandas method (for example df.plot.line()), not a matplotlib function.
Options 1 and 4: line() is not a pyplot function, and pltplot() is not valid because the . between plt and plot is missing.
Use plt.show() after plt.plot() to display the graph.
Related questions:
2026: 13 May Shift 2