Python Matplotlib Interview Questions and Answers
Question: What is the purpose of `plt.legend()` in Matplotlib?Answer: `plt.legend()` is used to add a legend to the plot, providing information about the plotted data series.Example:
|
Is it helpful?
Yes
No
Most helpful rated by users:
- How can you add labels to the x-axis and y-axis in a Matplotlib plot?
- Explain the purpose of the `plt.grid()` function in Matplotlib.