Question 21

What is the purpose of the legend() function in Matplotlib?

  1. ATo add a title to a plot
  2. BTo add annotations to a plot
  3. CTo label different lines or markers on a plot
  4. DTo label the x and y axes of a plot
Show answerHide answer

Correct answer: (C) To label different lines or markers on a plot

Explanation

legend() adds a legend box that labels each line or marker on the plot, using the label= values given when plotting.

From DSSSB TGT Computer Science Practice Set 4

This is question 21 of DSSSB TGT Computer Science Practice Set 4. See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.