carl walters
carl walters

Reputation: 159

How to change seaborn regplot scattplot to lineplot?

I am trying to change the scatterplot to be a lineplot I have attempted to try using plot.lines[0].set_linestyle("-") however this only affects the regression line which is already a lineplot.

I understand if I used sns.lineplot their is a setting in their to turn on regression however I am trying to do this using regplot.

df = pd.DataFrame({"x": [1, 2, 3, 4, 5, 6], "y": [10, 30, 60, 90, 60, 30]})

plot = sns.regplot(x="x", y="y", data=df, ci=65)

plt.show()

The reason I want to change the scatterplot to a lineplot is beacouse its hard to see whats going on with large datasets other whys.

To clarify I am trying display a lineplot instead of a scatterplot for the original data.

Upvotes: 2

Views: 1003

Answers (1)

Chris
Chris

Reputation: 16147

This looks a bit odd, but I'm guessing it's what you want?

import seaborn as sns
df = pd.DataFrame({"x": [1, 2, 3, 4, 5, 6], "y": [10, 30, 60, 90, 60, 30]})
sns.regplot(x="x", y="y", data=df, ci=65,scatter=False)
sns.lineplot(x="x", y="y", data=df)

enter image description here

Upvotes: 2

Related Questions