Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

How to Add a Title to Seaborn Plots

# import pandas library
import pandas as pd
from pyparsing import line
import seaborn as sns
import matplotlib.pyplot as plt

# create pandas DataFrame
df = pd.DataFrame({'team': ['India', 'South Africa', 'New Zealand', 'England'],
                   'points': [10, 8, 3, 5],
                   'runrate': [0.5, 1.4, 2, -0.6],
                   'wins': [5, 4, 2, 2]})

# plot the data frame
line_plt = sns.lineplot(data = df)
line_plt.set(title = "ICC World Cup Standings")
plt.show()
Comment

How to Add a overall Title to Seaborn Plots

Add overall title to seaborn using suptitle() method
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

# create pandas DataFrame
df = pd.DataFrame({'wins': [12, 11, 10, 3, 11, 20, 2, 30, 12,7],
                   'lost': [6, 4, 5, 3, 10, 7, 2, 12, 0, 6],
                   'team': ['A', 'A', 'A', 'A', 'A', 'B', 'B', 'B', 'B', 'B']})

# plot the data frame
rel = sns.relplot(data=df, x='wins', y='lost', col='team')

# add overall title
rel.fig.suptitle('ICC World Cup Standings')
plt.show()
Comment

PREVIOUS NEXT
Code Example
Python :: handling timezone in python 
Python :: cv2 assertion failed 
Python :: py array contains 
Python :: python index for all matches 
Python :: for i in range 
Python :: numpy argsort 
Python :: docstring in python 
Python :: pandas join dataframe 
Python :: check if string is python 
Python :: run python module from command line 
Python :: Async-Sync 
Python :: double underscore methods python 
Python :: api testing python 
Python :: sample hyperparameter tuning with grid search cv 
Python :: how to make loops in python 
Python :: request foucus tkinter widget 
Python :: replace nan in pandas column with mode and printing it 
Python :: plt.hist bins 
Python :: greater and less than in python 
Python :: python how to restart thread 
Python :: python floor float 
Python :: change the format of date in python 
Python :: how to print second largest number in python 
Python :: python calling method from constructor 
Python :: create payment request in stripe 
Python :: watershed segmentation 
Python :: Yield Expressions in python 
Python :: Python NumPy ndarray flatten Function Syntax 
Python :: pybase64 
Python :: find position of key in dictionary python 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =