I'd like to color with different hues the different points on the graph, but retain a single regression line.
At the moment setting hue='foo' in an lmplot draws a differrent regression line for every hue, whils i would like to retain a single one(the one you get if you don't set hue) but color the points. is it possible ?
From lmplot's perspective (actually from FacetGrid's) the scatterplot and regression line are considered one item, but you could do something like this:
g = sns.lmplot(x="x", y="y", hue="g", data=df, fit_reg=False)
sns.regplot(x="x", y="y", data=df, scatter=False, ax=g.axes[0, 0])
This won't work with multiple column or row facets.
Thanks, that's really what I was looking for. I've just used a for loop on
the variable I'd have set as col to to get around the lack of it, not as
nice but works none the less, thanks a lot
Lorenzo
On Tue, Feb 10, 2015 at 5:18 PM, Michael Waskom [email protected]
wrote:
From lmplot's perspective (actually from FacetGrid's) the scatterplot and
regression line are considered one item, but you could do something like
this:g = sns.lmplot(x="x", y="y", hue="g", data=df, fit_reg=False)
sns.regplot(x="x", y="y", data=df, scatter=False, ax=g.axes[0, 0])This won't work with multiple column or row facets.
—
Reply to this email directly or view it on GitHub
https://github.com/mwaskom/seaborn/issues/443#issuecomment-73729039.
I also used this way to generate regression plot with two colors. However, the figure size is unable to be adjusted for some reason. It remains small even when I keep increasing the figure size via "plt.figure(figsize=(20,20))". Every time, when the figure is generated, this figure size message is also printed: "
Most helpful comment
From lmplot's perspective (actually from FacetGrid's) the scatterplot and regression line are considered one item, but you could do something like this:
This won't work with multiple column or row facets.