close

How to increase the font size of the legend in my Seaborn plot?

Hello Guys, How are you all? Hope You all Are Fine. Today We Are Going To learn about How to increase the font size of the legend in my Seaborn plot in Python. So Here I am Explain to you all the possible Methods here.

Without wasting your time, Let’s start This Article.

Table of Contents

How to increase the font size of the legend in my Seaborn plot?

  1. How to increase the font size of the legend in my Seaborn plot?

    There is a much easier way to do this today, simply set up your figure and then call
    plt.legend(fontsize='x-large', title_fontsize='40')

  2. increase the font size of the legend in my Seaborn plot

    There is a much easier way to do this today, simply set up your figure and then call
    plt.legend(fontsize='x-large', title_fontsize='40')

Method 1

Use matplotlib function setp according to this example:

import seaborn as sns
import matplotlib.pylab as plt
sns.set_style("whitegrid")
tips = sns.load_dataset("tips")

ax = sns.stripplot(x="sex", y="total_bill", hue="day", data=tips, jitter=True)
plt.setp(ax.get_legend().get_texts(), fontsize='22') # for legend text
plt.setp(ax.get_legend().get_title(), fontsize='32') # for legend title

plt.show()
enter image description here

Method 2

There is a much easier way to do this today, simply set up your figure and then call

plt.legend(fontsize='x-large', title_fontsize='40')

Might depend on the version of matplotlib you’re using. I’m using 2.2.3 and it has the fontsize parameter but not the title_fontsize.

Summery

It’s all About this issue. Hope all Methods helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which Method worked for you? Thank You.

Also, Read