我试图在quantmod::chart_Series()的顶部绘制一些支撑线/阻力线。问题是,有趣的支撑线/阻力线在当前时间之前的系列数据范围之外(低于或高于)(我还想将图表向右扩展一点,超出数据的最后一个时间戳)。
查看quantmod::chart_Series()的源代码,我看不到指定ylim/xlim的方法,也看不到在“旧时代”使用yrange覆盖y-scale的quantmod::chartSeries的可能性。评论这里https://r-forge.r-project.org/scm/viewvc.php?view=rev&root=quantmod&revision=520也证实了我的预感。
我的诊断是否正确,或者是否有一种方法可以在quantmod::chart_Series中启用y比例覆盖?任何想法如何做我想要的高度感谢。
谢谢。
最好的,Samo
发布于 2012-06-20 04:46:56
chart_Series()
的帮助页面--三次!--说明它是实验性的,所以可能最终的改进版本会有很好的句柄来设置这些限制。
在此之前,这里有一个黑客攻击(?)这将允许您设置限制,和可能会教您一些关于chart_Series()
如何工作的知识(例如,通过创建"replot"
类的环境/闭包,该类存储了创建图表所需的所有信息)。
## Create an example plot
getSymbols("YHOO")
myChob <- chart_Series(YHOO)
## Plot it, with its default xlim and ylim settings
myChob
## Get current xlim and ylim settings for `myChob` (chob = chart object)
myxlim <- myChob$get_xlim()
myylim <- myChob$get_ylim()
## Alter those limits
myxlim <- c(1, 2000)
myylim[[2]] <- structure(c(0, 50), fixed=TRUE)
## Use the setter functions in the myChob environment to set the new limits.
## (Try `myChob$set_ylim` and `ls(myChob$Env)` to see how/where these are set.)
myChob$set_ylim(myylim)
myChob$set_xlim(myxlim)
## Plot the revised graph
myChob
https://stackoverflow.com/questions/11108206
复制相似问题