本文介绍了plot.xts + abline 不太准确?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 xtsExtra
来绘制一些 xts 对象的散点图,并想绘制一条穿过零的水平线,但看起来它在错误的位置...请看下面的代码?这是一个错误吗?
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')
推荐答案
Jeff Ryan 可能已经回答了这个问题 这里:
Jeff Ryan may have answered this here:
试试,
abline(v=.index(X)[50], col="red")
注意.index
中的点".事实是 xts
使用内部POSIXct(like)
x 轴的时间,因此您需要以这种方式访问它.
Note the "dot" in .index
. The fact is that xts
uses the internalPOSIXct(like)
time for the x-axis, so you need to access it that way.
这篇关于plot.xts + abline 不太准确?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!