I was wondering why seaborn lmplot and regplot only has the option to do logx. I have a frequent use to linearly fit log(y) ~ x and the Y-axis should always be in log scale to show the correlation (as a convention).
Is this something that can be done in Seaborn?
An option of logy=True would be nice...
Thanks.
To make the x-axis to log scale, we first the make the scatter plot with Seaborn and save it to a variable and then use set function to specify 'xscale=log'. We see a linear pattern between lifeExp and gdpPercap. Now, the scatter plot makes more sense.
While regplot() always shows a single relationship, lmplot() combines regplot() with FacetGrid to show multiple fits using hue mapping or faceting.
regplot() : This method is used to plot data and a linear regression model fit. There are a number of mutually exclusive options for estimating the regression model.
lmplot() method is used to draw a scatter plot onto a FacetGrid.
You can simply set the y-axis scale to log with:
import seaborn as sns; sns.set(color_codes=True)
tips = sns.load_dataset("tips")
ax = sns.regplot(x="total_bill", y="tip", data=tips)
ax.set_yscale('log') # set_yscale is a function, not a string
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