Adding title using set method
set 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 and average temperatures
Python3
# import necessary packages import pandas as pd import seaborn as sns # create a dataframe temperature = pd.DataFrame({ 'Month' : [ 'Jan' , 'Feb' , 'Mar' , 'Apr' , 'May' , 'Jun' , 'Jul' , 'Aug' , 'Sep' , 'Oct' , 'Nov' , 'Dec' ], 'Avg_Temperatures' : [ 22 , 25 , 28 , 32 , 35 , 44 , 38 , 32 , 25 , 23 , 20 , 18 ]}) # plot a line plot and set title sns.lineplot(x = 'Month' , y = 'Avg_Temperatures' , data = temperature). set ( title = "Monthly Avg Temperatures" ) |
Output
How to Add a Title to Seaborn Plots?
In this article, we will discuss how to add a title to Seaborn Plots in Python.
Contact Us