Reputation: 31
I want seaborn to do a pairplot in an already defined figure. However it creates a new figure when sns.pairplot is called.
For example, the following code creates two figures, the first blank and the second containg the pairplot.
import seaborn as sns
import matplotlib.pyplot as plt
iris = sns.load_dataset('iris')
fig,ax = plt.subplots(figsize=(9,9))
g = sns.pairplot(iris, hue='species')
The reason I want to use the existing figure is so that I can change the figsize and other figure attributes easily. Any suggestions?
Upvotes: 3
Views: 2274
Reputation: 36635
Use rcParams
to specify figure attributes:
plt.rcParams['figure.figsize']=(9,9)
then plot without calling fig,ax = plt.subplots(figsize=(9,9))
.
You can not set existing fig
instance according to FacetGrid class of seaborn. You can control figure size by number of columns and rows and with size
and aspect
arguments of pairplot. FacetGrid
calculate figure size as figsize = (ncol * size * aspect, nrow * size)
.
Upvotes: 2