How to Add Labels in a Plot using Python? Last Updated : 06 Dec, 2022 Comments Improve Suggest changes Like Article Like Report 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 Python # python program to plot graph without labels import matplotlib import matplotlib.pyplot as plt import numpy as np # it will take x coordinates by default # starting from 0,1,2,3,4... y = np.array([3, 8, 1, 10]) plt.plot(y) plt.show() Output: Plot without Labels or TitleCreating 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 Python # python program for plots with label import matplotlib import matplotlib.pyplot as plt import numpy as np # Number of children it was default in earlier case x = np.array([0, 1, 2, 3]) # Number of families y = np.array([3, 8, 1, 10]) plt.plot(x, y) # Label for x-axis plt.xlabel("Number of Childrens") # Label for y-axis plt.ylabel("Number of Families") plt.show() # for display Output: Plot with Labels 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") Example: Python3 # python program for plots with label import matplotlib import matplotlib.pyplot as plt import numpy as np # Number of children it was default in earlier case x = np.array([0, 1, 2, 3]) # Number of families y = np.array([3, 8, 1, 10]) plt.plot(x, y) # Label for x-axis plt.xlabel("Number of Childrens") # Label for y-axis plt.ylabel("Number of Families") # title of the plot plt.title("Survey Of Colony") plt.show() # for display   Output:  Plot with TitleSet 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.  Python # Adding font properties to labels and titles import matplotlib import matplotlib.pyplot as plt import numpy as np # Number of Children x = np.array([0, 1, 2, 3]) # Number of Families y = np.array([3, 8, 1, 10]) # label including this form1 will have these properties form1 = {'family': 'serif', 'color': 'blue', 'size': 20} # label including this form2 will have these properties form2 = {'family': 'serif', 'color': 'darkred', 'size': 15} plt.plot(x, y) plt.xlabel("Number of Childrens", fontdict=form1) plt.ylabel("Number of Families", fontdict=form1) plt.title("Survey Of Colony", fontdict=form2) plt.show() Output: Plot with Font Properties Comment More infoAdvertise with us Next Article How to Add Labels in a Plot using Python? A ayush70781 Follow Improve Article Tags : Technical Scripter Python Technical Scripter 2020 Python-matplotlib Practice Tags : python Similar Reads How To Adjust Position of Axis Labels in Matplotlib? Matplotlib is a powerful Python library for creating graphs and charts. By default, it places axis labels in standard positions, but sometimes you might want to move them for better readability or design. This article explains easy ways to adjust the position of axis labels in Matplotlib to make you 3 min read How to Add Markers to a Graph Plot in Matplotlib with Python? In this article, we will learn how to add markers to a Graph Plot in Matplotlib with Python. For that just see some concepts that we will use in our work. Graph Plot: A plot is a graphical technique for representing a data set, usually as a graph showing the relationship between two or more variable 2 min read How to Plot a Dataframe using Pandas Pandas plotting is an interface to Matplotlib, that allows to generate high-quality plots directly from a DataFrame or Series. The .plot() method is the core function for plotting data in Pandas. Depending on the kind of plot we want to create, we can specify various parameters such as plot type (ki 8 min read Matplotlib.axes.Axes.set_label() in Python Matplotlib is a library in Python and it is numerical â mathematical extension for NumPy library. The Axes Class contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. And the instances of Axes supports callbacks through a callbacks attribute. 2 min read Matplotlib.axis.Tick.get_label() in Python Matplotlib is a library in Python and it is numerical â mathematical extension for NumPy library. It is an amazing visualization library in Python for 2D plots of arrays and used for working with the broader SciPy stack. matplotlib.axis.Tick.get_label() Function The Tick.get_label() function in axis 2 min read How to Add Axes to a Figure in Matplotlib with Python? Matplotlib is a library in Python used to create figures and provide tools for customizing it. It allows plotting different types of data, geometrical figures. In this article, we will see how to add axes to a figure in matplotlib. We can add axes to a figure in matplotlib by passing a list argument 2 min read Adding labels to a Bokeh plot Bokeh includes several layout options for arranging plots and widgets. They make it possible to arrange multiple components to create interactive dashboards or data applications. The layout functions let you build a grid of plots and widgets. You can nest as many rows, columns, or grids of plots tog 3 min read Matplotlib.axis.Axis.set_label() function in Python Matplotlib is a library in Python and it is numerical â mathematical extension for NumPy library. It is an amazing visualization library in Python for 2D plots of arrays and used for working with the broader SciPy stack. Matplotlib.axis.Axis.set_label() Function The Axis.set_label() function in axis 2 min read Matplotlib.axis.Tick.set_label() function in Python Matplotlib is a library in Python and it is numerical â mathematical extension for NumPy library. It is an amazing visualization library in Python for 2D plots of arrays and used for working with the broader SciPy stack. Matplotlib.axis.Tick.set_label() Function The Tick.set_label() function in axis 2 min read How to Add Multiple Axes to a Figure in Python In this article, we are going to discuss how to add multiple axes to a figure using matplotlib in Python. We will use the add_axes() method of matplotlib module to add multiple axes to a figure. Step-by-step Approach: Import required modulesAfter importing matplotlib, create a variable fig and equal 3 min read Like