seaborn: lmplot() got an unexpected keyword argument 'figsize'
Compare these two ways of setting the size of a chart:
Generating a linear model plot
sns.lmplot(data=conversion, x='Week Index', y='Lead-Ann', height=4, aspect=5)
Creating figure with a regression plot
plt.figure(figsize=(24,4))
sns.regplot(data=conversion, x='Week Index', y='Lead-Ann')
The difference is explained the Seaborn documentation: seaborn.lmplot
Understanding the difference between regplot() and lmplot() can be a bit tricky. In fact, they are closely related, as lmplot() uses regplot() internally and takes most of its parameters. However, regplot() is an axes-level function, so it draws directly onto an axes (either the currently active axes or the one provided by the ax parameter), while lmplot() is a figure-level function and creates its own figure, which is managed through a FacetGrid. This has a few consequences, namely that regplot() can happily coexist in a figure with other kinds of plots and will follow the global matplotlib color cycle. In contrast, lmplot() needs to occupy an entire figure, and the size and color cycle are controlled through function parameters, ignoring the global defaults.
In Seaborn 0.9.0, I think the correct way to do this is to use height
(default of 5) to set the height of the figure and then use aspect
(default of 1) to set the width. height * aspect = width
.
To make a larger square, just increase the height:
sns.lmplot(x='x', y='y', hue='category', data=df, height=7);
To make it wider as well, increase the aspect ratio:
sns.lmplot(x='x', y='y', hue='category', data=df, height=7, aspect=1.6);
Since an lmplot
is "figure-level", figsize
is determined by two parameters, size
and aspect
. I think size=7
will do what you want but I may be way off.
Here it is in the docs (search for "Change the height and aspect ratio of the facets"): http://seaborn.pydata.org/generated/seaborn.lmplot.html
Note: I have been endlessly confused by the exact same thing, and it would be really nice for sizing to have a consistent interface.