How to Change Font Size in Seaborn Plots (With Examples)

To change the font size in a Seaborn plot, you can use the set() function to set the font scale parameter, which controls the size of text elements in the plot. For example, setting the font scale to 1.5 will make the text elements 50% larger than the default size. The font size can also be set explicitly using the font_scale parameter of the set() function. The font size can be further modified by setting the rcParams of the plot to a dictionary with the font size specified.


You can use the following basic syntax to change the font size in Seaborn plots:

import seaborn as sns

sns.set(font_scale=2)

Note that the default value for font_scale is 1. By increasing this value, you can increase the font size of all elements in the plot.

The following examples show how to use this syntax in practice.

Example 1: Change Font Size of All Elements in Seaborn Plot

The following code shows how to create a simple line chart in Seaborn with the default font size:

import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

#create DataFrame
df = pd.DataFrame({'date': ['1/1/2021', '1/30/2021', '1/1/2021', '1/30/2021'],
                   'sales': [4, 11, 6, 18],
                   'company': ['A', 'A', 'B', 'B']})

#plot multiple lines
sns.lineplot(x='date', y='sales', hue='company', data=df).set(title='Sales Data')

And the following code shows how to use the sns.set() function to increase the font size of all elements in the plot:

import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

#increase font size of all elements
sns.set(font_scale=2)

#create DataFrame
df = pd.DataFrame({'date': ['1/1/2021', '1/30/2021', '1/1/2021', '1/30/2021'],
                   'sales': [4, 11, 6, 18],
                   'company': ['A', 'A', 'B', 'B']})

#plot multiple lines
sns.lineplot(x='date', y='sales', hue='company', data=df).set(title='Sales Data')

Seaborn plot with specific font size

Notice that the font size for each element in the plot has increased dramatically.

Example 2: Change Font Size of Specific Elements in Seaborn Plot

The following code shows how to change the font size of specific elements in a Seaborn plot:

import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

#create DataFrame
df = pd.DataFrame({'date': ['1/1/2021', '1/30/2021', '1/1/2021', '1/30/2021'],
                   'sales': [4, 11, 6, 18],
                   'company': ['A', 'A', 'B', 'B']})

#plot multiple lines
sns.lineplot(x='date', y='sales', hue='company', data=df)

#modify individual font size of elements
plt.legend(title='Company', fontsize=20)
plt.xlabel('Date', fontsize=16);
plt.ylabel('Sales', fontsize=16);
plt.title('Sales Data', fontsize=20)
plt.tick_params(axis='both', which='major', labelsize=14)

Notice that each element in the plot has a unique font size based on the value specified in the fontsize argument.

The following tutorials explain how to perform other common operations in Seaborn:

x