【发布时间】:2013-12-10 18:46:47
【问题描述】:
我的问题是我从正态分布生成了一个时间序列并绘制了我的时间序列,但我想将时间序列和轴 X 之间的正区域涂成红色,轴 X 下方的负区域也是如此和我的时间序列。
这是我使用的代码,但它不起作用:
x1<-rnorm(250,0.4,0.9)
x <- as.matrix(x1)
t <- ts(x[,1], start=c(1,1), frequency=30)
plot(t,main="Daily closing price of Walterenergie",ylab="Adjusted close Returns",xlab="Times",col="blue")
plot(t,xlim=c(2,4),main="Daily closing price of Walterenergie",ylab="Adjusted close Returns",xlab="Times",col="blue")
abline(0,0)
z1<-seq(2,4,0.001)
cord.x <- c(2,z1,4)
cord.y <- c(0,t(z1),0)
polygon(cord.x,cord.y,col='red')
【问题讨论】: