I have a scatter plot created using plotly express with two subplots (facet_col=“Category”) (as per https://plotly.com/python/facet-plots/)
Each subplot has several sets of markers by Year (in different colours), each with their own trendline.
The default hovertemplate for these lines looks like this:
**OLS Trendline** y_var = 0.083808 * x_var + -4.199356 R^2 = 0.846987 Year = 2020 Category = A x_var = 20.285 y_var = 6.53478 (trend)
I would like to be able to customise this hovertemplate (for the trendline only), but I don’t really know how to do this.
I’m aware of get_trendline_results and also using fig.update_traces(hovertemplate=something, selector = dict(type=‘scattergl’, mode=‘lines’)), but actually working out how to recreate the default hovertemplate and tweak it slightly is quite difficult.
Things I’d like to be able to do include changing the title, the number formatting, removing elements, but I crucially still want to display the equation (with better number formatting) and the R-squared value, as well as some column values.
I’d be grateful for any help you can give - thanks!