如何在回归曲线上添加回归线?

时间:2019-07-03 20:33:27

标签: r ggplot2 data-visualization gganimate

我想在我的gganimate图上添加一条回归线。在没有回归线的情况下,gganimate图可以按预期工作,并且当我将geom_smooth命令添加到常规图时,它可以正常工作。当我尝试将回归线添加到gganimate图时,我只会收到一个错误。

g <- ggplot(pdata, aes(x = ole, y = rsv)) + 
        geom_point(aes(color = region)) + 
        geom_smooth(aes(group = region, color = region), se = FALSE)

anim <- g + transition_states(region, transition_length = 3, state_length = 5) 
anim

我收到错误消息:

 geom_smooth()` using method = 'loess' and formula 'y ~ x'
`geom_smooth()` using method = 'loess' and formula 'y ~ x'
Error in transform_path(all_frames, next_state, ease, params$transition_length[i],  : 
  transformr is required to tween paths and lines

0 个答案:

没有答案