question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using regplot with scatter=False. Not working as intended?

See original GitHub issue

Hi, I’m trying to draw a regression plot showing just the regression line and confidence interval bands, without the points in the scatter plot, though running the following does not seem to work as I expected.

import seaborn as sb
x = np.linspace(0, 10, 100)
e = np.random.normal(size=100)
y = 1 + 0.5*x + 2*e

g = sb.regplot(x, y, scatter=False)
g.set(xlim=(min(x), max(x)), ylim=(-2, 8))

The following code produces a band that only extends for a small portion of the x and y range.

image

I can work around it by explicitly setting the point colour to white, but I feel there should be a better way to do it.

g = sb.regplot(x, y, scatter_kws={"color": "white"})
g.set(xlim=(min(x), max(x)), ylim=(-2, 8))

image

Have I missed out a parameter I need to do this, or is this a bug?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
mwaskomcommented, Apr 5, 2016

sns.regplot(x="total_bill", y="tip", data=tips, scatter_kws=dict(alpha=0))

0reactions
pkchcommented, Apr 5, 2016
tips = sns.load_dataset("tips")

# everything is fine
sns.regplot(x="total_bill", y="tip", data=tips)

plt.figure()
# the regression line extends only from 18.5 to 21 on the x axis, as described by OP
sns.regplot(x="total_bill", y="tip", data=tips, scatter=False)

# the fix as explained above by @mwaskom works perfectly
# except we have to manually calculate xlim values :(
f, ax= plt.subplots()
ax.set(xlim=(min(tips['total_bill']), max(tips['total_bill'])))
sns.regplot(x="total_bill", y="tip", data=tips, scatter=False)

plt.figure()
# I thought this would also show the full regression line as suggested above but it didn't
sns.regplot(x="total_bill", y="tip", data=tips, scatter=False, truncate=True)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is an intercept displayed incorrectly when plotting ...
1 Answer 1 · The solution did not work as expected. · set_ylim(0,) takes 2 parameters. · There is a problem with configuring...
Read more >
seaborn.regplot — seaborn 0.12.1 documentation - PyData |
Plot data and a linear regression model fit. There are a number of mutually exclusive options for estimating the regression model. See the...
Read more >
Creating Diagnostic Plots in Python - Robert Alvarez
We will be looking at four main plots in this post and describe how each of them can be used to diagnose issues...
Read more >
Advanced visualization tutorial with Seaborn – Datalore Report
In this visualization tutorial you will learn how to use the Seaborn library to ... These ones are intended not for 3D graphics...
Read more >
Multi-factor model using Ordinary least Squares Regression
The best practice while working with stock prices is to use adjusted ... sns.regplot(model_leverage, model_norm_residuals,scatter=False, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found