plot.xts + abline not quite accurate?

纵饮孤独 提交于 2019-12-13 00:16:34

问题


I am using xtsExtra to plot some scatter graphs of xts objects and wanted to draw a horizontal line through zero but it looks like its in the wrong place...please see the code below? is this a bug?

set.seed(123)
require(xts)
f <- xts(rnorm(100,0.0001,0.003),Sys.Date()-c(100:1))
f1 <- xts(rnorm(100,0.0001,0.003),Sys.Date()-c(100:1))
require(xtsExtra)
plot(f,f1)
abline(h=0,col='red')

回答1:


Jeff Ryan may have answered this here:

Try,

abline(v=.index(X)[50], col="red")

Note the "dot" in .index. The fact is that xts uses the internal POSIXct(like) time for the x-axis, so you need to access it that way.



来源:https://stackoverflow.com/questions/18923382/plot-xts-abline-not-quite-accurate

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!