近期做时间序列预测,无奈自带的预测图像太渣太难看。于是用ggplot2自己调整出一张漂亮的图。
时间序列预测图,很能体现图层的概念:
* 因为存在预测区间,先画线点,会被预测区间覆盖,所以要注意图层顺序。
* 时间序列图,使用自带画图背景输出效果不佳,白色网格效果更好一点。
* 案例一为原始时间序列图(图层概念),案例二为优化预测通道后展示图(图例修改)
Example1
##整理出两个画图数据,原始数据freq_xts(学习集和检验集)以及预测数据##forcastConsequence
ArimaForecastPlot <- function(freq_xts, forcastConsequence){
g <- ggplot()
g <- g + geom_ribbon(aes(ymin=forcastConsequence[,6], ymax=forcastConsequence[,7], x=forcastConsequence[,1]), fill="lightskyblue", alpha=0.2) ##预测区间大
g <-