首页 > 解决方案 > 使用自动绘图为线性模型上使用的 ggfortify 对象生成交互式绘图

问题描述

我正在尝试ggfortify根据基于此数据的多元回归模型为对象生成交互式图。以下是我到目前为止所做的。如何ggfortify使用 为该对象生成交互式绘图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'

更新

好的,所以我可以通过首先指定要强化的感兴趣的地块来解决这个问题。虽然,我不知道为什么现在错误消失了。

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

在此处输入图像描述

但是现在autoplotly没有正确显示QQ情节。

在此处输入图像描述

标签: ggfortify

解决方案


根据文档,shareY参数告诉函数是否在子图中共享 y 轴。

尝试这个:

autoplotly(lm.plot, shareY = FALSE)

推荐阅读