2018年7月29日日曜日

compare PAYEMS and S&P500


Use classic plot function.

  • Don't forget to use as.Date to convert index to x-axis, otherwise axis will loose away.
  • Locate "axis" sentence in the script with a full caution. It may work at other places but may not either.

plot.default(as.Date(index(to.monthly(SP5)[kikan][,1])),to.monthly(SP5)[kikan][,1],axes=T,type='l',ylim=c(400,3000))
axis(side=2, pos=as.Date("2017-01-01"))
par(new=T)
plot.default(as.Date(index(to.monthly(SP5)[kikan][,1])),rep(2700,length(index(to.monthly(SP5)[kikan][,1]))),type='l',col=3,ylim=c(400,3000))
par(new=T)
plot.default(diff(PA[kikan]),axes=F,ylim=c(-900,900),col=2,type='h')




> to.monthly(SP5)[kikan][200]
        SP5.Open SP5.High SP5.Low SP5.Close  SP5.Volume
 8 2008  1269.42  1313.15 1247.45   1282.83 86266010000

plot.default(as.Date(index(to.monthly(SP5)[kikan][,1])),to.monthly(SP5)[kikan][,1],axes=T,type='l',ylim=c(400,3000),first=grid(28,10),tck=0.01)
par(new=T)
plot.default(diff(PA[kikan]),axes=F,ylim=c(-900,900),col=2,type='h')
abline(v=200)   # draw v-line at 2008 August
par(new=T)
plot.default(as.Date(index(to.monthly(SP5)[kikan][,1])),rep(1282,length(index(to.monthly(SP5)[kikan][,1]))),type='l',col=3,ylim=c(400,3000))




0 件のコメント: