I used autoplot
to create simple lm
plots by using the code below. But when I use autoplotly
to make an interactive plot, the title disappears that's generated by autoplot
, and even if I use ggplot2::ggtitle
, the title still doesn't show up. How can I fix this? The CSV can be downloaded from here.
# Read file
df = read,csv(Mean_SWE.csv)
# Run the model
Model = lm(formula = SWE ~ Mean.Z + Intensity.mean, data = df)
# Plot
lm.plot.rsd = autoplot(Model, label.size = 3, which = 1) +
theme_bw()
autoplotly(lm.plot.rsd) +
ggplot2::ggtitle("Residuals vs Fitted")
autoplot
createsggmultiplot
object (lm.plot.rsd
) which is stripped of all of its titles in autoplotly in order to call plotly functions properly. The solution is to passggplot
object toautoplotly
. So, take theggplot
that you need out ofggmultiplot
, like thislm.plot.rsd@plots[[1]]
Try this: