What is the purpose of the legend() function in Matplotlib?
2023
What is the purpose of the legend() function in Matplotlib?
- A.
To add a title to a plot
- B.
To add annotations to a plot
- C.
To label different lines or markers on a plot
- D.
To label the x and y axes of a plot
Attempted by 1544 students.
Show answer & explanation
Correct answer: C
The legend() function displays a legend box that identifies different plotted lines or markers using their labels.