What is the purpose of the plt.legend() function in Matplotlib?
Correct answer
A. To set the plot legend
17 views
A. To set the plot legend
17 views
plt.legend() adds a legend to the plot, identifying each line or series by the label given when it was plotted. The loc argument controls its position.
Without labels on the plotted series, the legend has nothing to show.
For more solved questions like this one, see Data Science MCQs on MCQsExam.com.
Not sure why the answer is A? Ask here and get an explanation.