How to add a title to a Matplotlib legend? Last Updated : 24 Jan, 2021 Comments Improve Suggest changes Like Article Like Report Prerequisites: Matplotlib In this article, we will see how can we can add a title to a legend in our graph using matplotlib, Here we will take two different examples to showcase our graph. Approach: Import required module.Create data.Add a title to a legend.Normally plot the data.Display plot. Below is the Implementation: Example 1: In this example, we will draw different lines with the help of matplotlib and Use the title argument to plt.legend() to specify the legend title. Python3 # importing package import matplotlib.pyplot as plt import numpy as np # create data X = [1, 2, 3, 4, 5] # plot lines plt.plot(X, np.sin(X), label = "Curve-1") plt.plot(X, np.cos(X), label = "Curve-2") # Add a title to a legend plt.legend(title = "Legend Title") plt.title("Line Graph - Geeksforgeeks") plt.show() Output: Example 2: In this example, we will draw a Bar Graph with the help of matplotlib and Use the title argument to plt.legend() to specify the legend title. Python3 # importing package import matplotlib.pyplot as plt # sample code plt.bar([1, 2, 3], [16, 4, 1], color ='yellow', label = 'Label 2') plt.bar([4, 5], [2, 4], label = 'Label 1') # Add a title to a legend plt.legend(title = "Variation Rate") plt.title("Line Graph - Geeksforgeeks") plt.show() Output: Comment More infoAdvertise with us Next Article How to add a title to a Matplotlib legend? S skrg141 Follow Improve Article Tags : Python Python-matplotlib Practice Tags : python Similar Reads How to add a legend to a scatter plot in Matplotlib ? Adding a legend to a scatter plot in Matplotlib means providing clear labels that describe what each group of points represents. For example, if your scatter plot shows two datasets, adding a legend will display labels for each dataset, helping viewers interpret the plot correctly. We will explore s 2 min read How to Add Title to Subplots in Matplotlib? In this article, we will see how to add a title to subplots in Matplotlib? Let's discuss some concepts : Matplotlib : Matplotlib is an amazing visualization library in Python for 2D plots of arrays. Matplotlib is a multi-platform data visualization library built on NumPy arrays and designed to work 3 min read How to add text to Matplotlib? Matplotlib is a plotting library in Python to visualize data, inspired by MATLAB, meaning that the terms used (Axis, Figure, Plots) will be similar to those used in MATLAB. Pyplot is a module within the Matplotlib library which is a shell-like interface to Matplotlib module. Â It provides almost any 5 min read How to Add a Title to Seaborn Plots? In this article, we will discuss how to add a title to Seaborn Plots in Python. Method 1: Adding title using set methodset method takes 1 argument "title" as a parameter which stores Title of a plot. Syntax set(title="Title of a plot") Example: Here, we are going to create a dataframe with months an 2 min read How to Create a Single Legend for All Subplots in Matplotlib? The subplot() function in matplotlib helps to create a grid of subplots within a single figure. In a figure, subplots are created and ordered row-wise from the top left. A legend in the Matplotlib library basically describes the graph elements. The legend() can be customized and adjusted anywhere in 3 min read Like