- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to increase the font size of the legend in my Seaborn plot using Matplotlib?
To increase the font size of the legend in a Seaborn plot, we can use the fontsize variable and can use it in legend() method argument.
Steps
Create a data frame using Pandas. The keys are number, count, and select.
Plot a bar in Seaborn using barplot() method.
Initialize a variable fontsize to increase the fontsize of the legend.
Use legend() method to place legend on the figure with fontsize in the argument.
To display the figure, use show() method.
Example
import pandas import matplotlib.pylab as plt import seaborn as sns plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True df = pandas.DataFrame(dict( number=[2, 5, 1, 6, 3], count=[56, 21, 34, 36, 12], select=[29, 13, 17, 21, 8] )) bar_plot1 = sns.barplot(x='number', y='count', data=df, label="count", color="red") bar_plot2 = sns.barplot(x='number', y='select', data=df, label="select", color="green") fontsize = 20 plt.legend(loc="upper right", frameon=True, fontsize=fontsize) plt.show()
Output
- Related Articles
- How to set the font size of Matplotlib axis Legend?
- How to change the font size of legend in base R plot?
- How to increase plt.title font size in Matplotlib?
- How to add a legend on Seaborn facetgrid bar plot using Matplotlib?
- Auto adjust font size in Seaborn heatmap using Matplotlib
- How to change the text color of font in the legend using Matplotlib?
- How to change xticks font size in a matplotlib plot?
- How to increase the font size of a Text widget?
- How to increase the font size of text in Arduino IDE?
- How to move the legend to outside of a Seaborn scatterplot in Matplotlib?
- How to increase the X-axis labels font size using ggplot2 in R?
- How to adjust the size of a Matplotlib legend box?
- How to plot multiple Seaborn Jointplot in Subplot using Matplotlib?
- How to modify the font size in Matplotlib-venn?
- How to plot multiple histograms on same plot with Seaborn using Matplotlib?

Advertisements