文字没有出现在XTS图上

时间:2013-08-19 11:50:23

标签: r plot xts

我在使用 xts 在R中为时间序列数据添加一些文本时遇到问题。我已经提出了一个简单的问题示例。

我的text()命令似乎什么也没做,而我可以在情节中加点。我试图通过尽可能使用默认值来保持代码简单

require(quantmod)

# fetch the data and plot it using default options
getSymbols('MKS.L')
plot(MKS.L$MKS.L.Close)

# try to add text - doesn't appear
text(as.Date('2012-01-01'),y=500,"wobble", cex=4)

# add a point - this does appear
testPos <- xts(600, as.Date('2012-01-01'))
points( testPos, pch = 3, cex = 4, col = "red" )

任何帮助表示感谢 - 我对R很新,我花了好几个小时!

1 个答案:

答案 0 :(得分:3)

不是直接答案,但plot.xts包附带的xts函数尚未完全开发。

使用xtsExtra软件包中的plot.zooplot.xts要好得多(该软件包是作为Google Summer of Code项目编写的,目的是将其转换为xts包)

其中任何一个都可行:

plot(as.zoo(MKS.L$MKS.L.Close))
text(as.Date('2012-01-01'),y=500,"wobble", cex=4)

#install.packages("xtsExtra", repos="http://r-forge.r-project.org")
xtsExtra::plot.xts(MKS.L$MKS.L.Close)
text(as.Date('2012-01-01'),y=500,"wobble", cex=4)
相关问题