How do I change the figure size for my lmplot in seaborn?
This is my current code, but apparently figsize
isn't accepted.
sns.lmplot(x="x", y="y", hue="category", data=df,fit_reg=False, markers=["o", "x"], palette="Set1",figsize=(7,7));
Thanks.
lmplot() method is used to draw a scatter plot onto a FacetGrid.
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.
Compare these two ways of setting the size of a chart:
sns.lmplot(data=conversion, x='Week Index', y='Lead-Ann', height=4, aspect=5)
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With