I would like to be able to show trend lines that are based on weighted least squares regression instead of ordinary least squares regression.

As far as I can tell, itâ€™s only possible to pass string values to the â€˜trend_lineâ€™ parameter in plotly.express.scatter and these strings are just aliases to functions implemented in px.trendline_functions.

Would it be possible to somehow pass a custom function for the trendline calculation? If not, any idea how I could add custom trendlines to a scatter plot somehow?