Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change a figure's size in Python Seaborn package

I'm having trouble increasing the size of my plot figures using Seaborn (imported as sns). I'm using sns.pairplot to plot columns of a data frame against one another.

    %matplotlib inline     plt.rcParams['figure.figsize']=10,10     columns=list(df.columns.values)     g=sns.pairplot(df, kind='reg', x_vars=columns,y_vars = ['Column 1']) 

The plots populate with data just fine, but the figure size is too small.

I thought plot.rCParams['figure.figsize'] would control how large the figure is, but it doesn't seem to take effect. I've tried a few different suggestions from online boards, but nothing seems to work.

like image 243
Vikram Josyula Avatar asked Oct 30 '15 22:10

Vikram Josyula


People also ask

How do I change my figure size in Seaborn Facetgrid?

You can use g. figure. set_size_inches(20, 12) to change the size, e.g. just before saving.

How do you increase the size of the Countplot in Seaborn?

from matplotlib import pyplot as plt import seaborn as sns plt. figure(figsize=(15,16)) sns. countplot(data=yourdata, ...) Save this answer.

How do I change the Y axis scale in Seaborn?

You can use the matplotlib. pyplot module's locator_params() method to change the axis scale. You can adjust the x-axis and y-axis at the same time with the code plt. locator_params(nbins = 10).


1 Answers

sns.pairplot "Returns the underlying PairGrid instance for further tweaking" ...for instance changing the figure size:

g=sns.pairplot(df, kind='reg', x_vars=columns,y_vars = ['Column 1']) g.fig.set_size_inches(15,15) 
like image 129
Martin Alexandersson Avatar answered Oct 02 '22 16:10

Martin Alexandersson