MYjx
MYjx

Reputation: 4407

Change the font size in a seaborn corrplot

My question is how to change the size of font in seaborn using correlation matrix I don't know why somehow the font is too large for mesee blow

Upvotes: 5

Views: 14894

Answers (6)

Priyamvada Singh
Priyamvada Singh

Reputation: 1

Use the following as one of the parameters in seaborn.heatmap():

annot_kws={'size':12}

Upvotes: 0

Tweety
Tweety

Reputation: 53

i did this at this works quite well.

enlarged the fig size to able to read it properly

 sns.set(style="white")
f, ax = plt.subplots(figsize=(20, 20))
sns.heatmap(bos.corr(),annot=True,annot_kws={"size":15})

Upvotes: 1

Joshua Zastrow
Joshua Zastrow

Reputation: 1403

I believe you can use the set method, modify the font scale parameter.

sns.set(font_scale=0.5)

Upvotes: 2

Gabriel
Gabriel

Reputation: 3797

if you already have the correlation values in your data, you can use a heatmap and set up the size with "annot_kws", for example here setting it to 8.

sns.heatmap(data, vmin=data.values.min(), vmax=1, square=True, 
        linewidths=0.1, annot=True, annot_kws={"size":8})

and it would look like this:

enter image description here

Upvotes: 13

Alan Baer
Alan Baer

Reputation: 11

If you're using set_context, then you can add a font scaling parameter along with the size of the plot.

sns.set_context("poster",font_scale=.7)

Upvotes: 1

mwaskom
mwaskom

Reputation: 49002

Regrettably I don't think that's configurable, but what I would recommend is just to make the figure larger e.g.

f, ax = plt.subplots(figsize=(10, 10))
sns.corrplot(df, ax=ax)

If that's not an option and you're primarily interested in the heatmap (not the numerical values), you could do

sns.corrplot(df, annot=False, sig_stars=False, diag_names=False)

Upvotes: 2

Related Questions