Prerequisites: Python Matplotlib
In this article, we will discuss adding labels to the plot using Matplotlib in Python. But first, understand what are labels in a plot. The heading or sub-heading written at the vertical axis (say Y-axis) and the horizontal axis(say X-axis) improves the quality of understanding of plotted stats.
Example: Let’s create a simple plot
Creating Labels for a Plot
By using pyplot() function of library we can add xlabel() and ylabel() to set x and y labels.
Example: Let’s add Label in the above Plot
If you would like to make it more understandable, add a Title to the plot, by just adding a single line of code.
plt.title("Survey Of Colony")
Set Font Properties for Titles and Labels
In order to make the Plot more attractive use the fontdict parameter in xlabel(), ylabel(), and title() to apply the font properties.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course