Using autoplotly to produce an interactive plot for a ggfortify object used on a linear model

87 views Asked by At

I am trying to produce an interactive plot for a ggfortifyobject based on a multivariate regression model based on this data. Below is what I have done so far. How can I produce interactive plots for this ggfortify object by using autoplotly?

library(ggfortify)
library(autoplotly)

# Construct a simple multivariate regression model 
# So it's something like this SWE ~ Mean.Z + Intensity.mean

Model = lm(formula = SWE ~ Mean.Z + Intensity.mean, data = df.mean.swe)

# Plot the model
lm.plot = autoplot(Model, label.size = 3) + theme_bw()

# Interactive
autoplotly(lm.plot)

Error in unique.default(x) : 
  unimplemented type 'expression' in 'HashTableSetup'

UPDATE

Okay, so I was able to get rid of the problem by first specifying the the plots of interest to fortify.Though, I don't know why the error went away now.

lm.plot = autoplot(Model, label.size = 3, which = 1:2) + theme_bw()

enter image description here

But now autoplotly is not showing the Q-Q plot properly.

enter image description here

1

There are 1 answers

0
damir On

According to the documentation, shareY argument tells the function whether or not to share y-axis among subplots.

Try this:

autoplotly(lm.plot, shareY = FALSE)