时间序列绘图范围 [英] Time series plot range

查看:41
本文介绍了时间序列绘图范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在绘制一个 xts 对象:

Hi am ploting a xts object:

我想将 xlim 延长到 2 月 30 日,因为我想添加来自 Arima 模型的预测:

And I would like to extend the xlim til 30-february because I want to add the prediction from an Arima model:

par(mfrow=c(1,1))
pred <- predict(try2, n.ahead = 1,se.fit=T)
lim_sup <- pred$pred + 1.96 * pred$se
lim_inf <- pred$pred - 1.96 * pred$se
plot(heat["1996-02-01 00:00/1996-02-16 04:00"],type="l",main="Cross Validation")
points(exp(pred$pred),col="blue",lwd=2)
points(exp(lim_sup),lwd=2,col="green")
points(exp(lim_inf),lwd=2,col="green")

但我看不到情节中的任何线条.你能给我一些建议吗?

But I can not see any lines in the plot. Could you give me some recommendation?

热度时间序列是这样的

                     HC.f
1996-02-01 00:00:00 1437.000
1996-02-01 01:00:00 1441.600
1996-02-01 02:00:00 1489.300
1996-02-01 03:00:00 1501.300
1996-02-01 04:00:00 1568.400
1996-02-01 05:00:00 1629.400

虽然一小时步长的预测:

While the predictions for one hour step:

pred$pred
Time Series:
Start = 3002 
End  = 3002 
Frequency = 1 
[1] 7.480588

推荐答案

在绘图前合并您的实际对象和预测对象.然后,您将在整个所需时间段内获得一个时间序列.

Merge your actual and prediction objects before plotting. Then you will have one time series over the full desired time period.

library(xts)
set.seed(21)
x <- xts(rnorm(10),Sys.Date()-10:1)
y <- xts(rnorm(3),Sys.Date()+0:2)
z <- merge(x,y)
plot(z[,1], ylim=range(z,na.rm=TRUE))
lines(z[,2],col='red')

这篇关于时间序列绘图范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆