【发布时间】:2019-09-04 05:05:39
【问题描述】:
尝试将 geom_points 添加到 autolayer() 行(图片中的“拟合”),这是 Rob Hyndmans 预测包中 ggplot2 的 autoplot() 的 wrapper 一部分(ggplot2 中也有一个基本的 autoplot/autolayer同样可能适用于那里)。
问题是(我不是 ggplot2 专家,并且 autoplot 包装器使它变得更棘手) geom_point() 适用于主调用,但我如何应用类似于 autolayer(拟合值)?
像普通 geom_line() 一样尝试 type="b" 但它不是 autolayer() 中的对象参数。
require(fpp2)
model.ses <- ets(mdeaths, model="ANN", alpha=0.4)
model.ses.fc <- forecast(model.ses, h=5)
forecast::autoplot(mdeaths) +
forecast::autolayer(model.ses.fc$fitted, series="Fitted") + # cannot set to show points, and type="b" not allowed
geom_point() # this works fine against the main autoplot call
【问题讨论】: