Reputation: 11
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
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