Skip to main contentSkip to solution

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.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question