How to show trend line equation when using ggplotly

I have a scatter chart with trend lines and tooltip(using ggplotly). I want to show the equations for these trend lines. When it is static(using only ggplot2), the equations are ok as shown below.
################below are code using ggplot2###########################
library(ggplot2)
library(ggpubr)
formula <- y ~ poly(x,2, raw = TRUE)
p= ggplot(data=dataset )+
geom_point(aes(x=load_percent, y=ME_SFOC,color=christianname),size=4,shape=1,stroke = 1)+
stat_smooth(method = "lm", formula = formula, aes(x=load_percent, y=ME_SFOC,fill=christianname,group = c(christianname),color=christianname), se = FALSE )+
stat_regline_equation(
aes(x=load_percent, y=ME_SFOC,group = c(christianname),color=christianname),
formula = formula,size=6
)+
theme(text = element_text(size=20),
panel.background = element_rect(fill = "white", colour = "white",
size = 2, linetype = "solid"),
axis.line=element_line(size = 1, linetype = 'solid',
colour = "black"),
panel.grid.major.x = element_blank()
) +
xlab("Load%") +ylab("ME FSOC") #+ggtitle("Load%/FSOC")
p
################above are code using ggplot2###########################

But they cannot be shown correctly with ggplotly(). Based on my code above, changing the last line 'p' to 'ggplotly(p)', the chart then changed to this:
ggplotly

How can I show the equation correctly?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.