【问题标题】:Autoplot time series - set fixed months/years to plotAutoplot 时间序列 - 设置固定的月份/年份来绘制
【发布时间】:2021-08-28 23:16:48
【问题描述】:
library(fpp)
library(forecast)

ausbeer.train <- window(ausbeer, end=c(1999,4))
ausbeer.test <- window(ausbeer, start=c(2000,1))

autoplot(ausbeer.train, xlab="Rok", ylab="beer") +
  autolayer(snaive(ausbeer.train, h=32), PI=FALSE, series="snaive") +
  autolayer(meanf(ausbeer.train, h=32), PI=FALSE, series="meanf") +
  autolayer(ausbeer.test)

生产

如果我只想绘制从 1995 年到 2008 年的数据怎么办?我可以以某种方式限制 x 轴上的范围吗?我不想对我的数据进行子集化(因为 snaive 和 meanf 以及其他方法可能需要整个训练数据),我只需要限制我在绘图上绘制的内容。

【问题讨论】:

    标签: r plot time-series


    【解决方案1】:

    如果 p 是问题中 autoplot 语句的值,那么这将仅绘制 1995 年到系列结尾。

    library(ggplot2)
    
    p + xlim(1995, NA)
    

    【讨论】:

    • 您还需要library(ggplot2)。谢谢,成功了!
    猜你喜欢
    • 2021-03-14
    • 2018-12-02
    • 1970-01-01
    • 2020-12-24
    • 2021-08-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-25
    相关资源
    最近更新 更多