- 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
Auto adjust font size in Seaborn heatmap using Matplotlib
To adjust font size in Seaborn, we can take followig steps−
- Create a dictionary with some mathematical expressions
- Create a dataframe using Pandas data frame.
- Create a heatmap using heatmap() method.
- To adjust the font size in Seaborn heatmap, change the fontsize value.
- To display the figure, use show() method.
Example
import numpy as np import seaborn as sns from matplotlib import pyplot as plt import pandas as pd plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True d = { 'y=1/x': [1 / i for i in range(1, 10)], 'y=x': [i for i in range(1, 10)], 'y=x^2': [i * i for i in range(1, 10)], 'y=x^3': [i * i * i for i in range(1, 10)] } df = pd.DataFrame(d) ax = sns.heatmap(df, vmax=1) plt.xlabel('Mathematical Expression', fontsize=16) plt.show()
Output
- Related Articles
- How to auto-adjust font size using CSS?
- CSS font-size-adjust Property
- How to make a heatmap square in Seaborn FacetGrid using Matplotlib?
- How to adjust transparency (alpha) in Seaborn pairplot using Matplotlib?
- How to increase the font size of the legend in my Seaborn plot using Matplotlib?
- Set Max value for color bar on Seaborn heatmap using Matplotlib
- Font size adjust of an element with CSS
- How to Adjust Marker Size in Matplotlib?
- How to animate a Seaborn heatmap or correlation matrix(Matplotlib)?
- Adding units to heatmap annotation in Seaborn
- How to increase plt.title font size in Matplotlib?
- How to modify the font size in Matplotlib-venn?
- How to adjust the size of a Matplotlib legend box?
- How to adjust the space between Matplotlib/Seaborn subplots for multi-plot layouts?
- How to change xticks font size in a matplotlib plot?

Advertisements