question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

heatmap annotation font size

See original GitHub issue

I am creating a heatmap with sns.heatmap() but couldn’t find a way to set the size of the labels inside the boxes when we set annot=True, is it possible to make the font smaller ?

Thanks

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

136reactions
mwaskomcommented, Jan 22, 2015

Use the annot_kws parameter, e.g.

sns.heatmap(x, annot=True, annot_kws={"size": 20})
0reactions
StevenLi-DScommented, Oct 8, 2022

@shayan911 each of the ticklabel is also an object and you can use .set_fontsize() method for it. Make sure you have set_ticklabels() first.

import matplotlib.pyplot as plt
x = [1, 2, 3]
y = [2, 4.5, 4]

fig, ax = plt.subplots()
ax.plot(x, y)

ax.set_xticks(x)
ax.set_xticklabels(x)

for label in ax.xaxis.get_ticklabels():
    if label.get_text() == '2':
        label.set_fontsize(20)

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Auto adjust font size in seaborn heatmap - Stack Overflow
when using seaborn heatmap, is there a way to auto-adjust the font size for it to fit exactly inside the squares? for example...
Read more >
How to increase the size of the annotations of a seaborn ...
Annotations are text that appears on a heatmap cell which represents what that cell represents. The annotations follow a default font size ......
Read more >
Auto adjust font size in Seaborn heatmap using Matplotlib
To adjust the font size in Seaborn heatmap, change the fontsize value. To display the figure, use show() method. Example. import numpy as...
Read more >
Increase Heatmap Font Size in Seaborn | Delft Stack
We can change the fontsize , fontweight , and fontfamily . The fontsize property will increase our heatmap font size. We can resize...
Read more >
Change fontsize/remove name of annotation ...
Hi all, I am experiencing an issue with my heatmap. When I draw a heatmap with row annotations, my row names disappear. I...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found