Joshua Schaafsma
Joshua Schaafsma

Reputation: 11

is there a way to make a plotly trendline intercept specific values?

I would like to know if someone knows of an easy way to make an OLS trendline in ploty express pass through the origin. I have been looking for quite some time now so it would be much appreciated.

Upvotes: 1

Views: 1176

Answers (1)

neelsnarayan
neelsnarayan

Reputation: 31

With plotly.express.scatter(), there is a trendline_options variable passed in as a dictionary. Set the add_constant key to False; i.e.

fig = px.scatter(df, x=x, y=y, trendline="ols", trendline_options={"add_constant": False})

Upvotes: 3

Related Questions