Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
680 views
in Technique[技术] by (71.8m points)

plot - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...