使用quantmod :: chart_Series()中的xlim/ylim或xrange/yrange覆盖y-scale和x-scale - 不可能?

Sam*_*amo 5 finance r quantmod

我试图在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-scale覆盖?任何想法如何做我想要的高度赞赏.

谢谢.

最好,萨摩

Jos*_*ien 6

chart_Series()笔记的帮助页面- 三次! - 它是实验性的,所以最终的抛光版本可能会有很好的手柄来设置这些限制.

在此之前,这里有一个hack(?),它可以让你设置限制,可以教你一些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
Run Code Online (Sandbox Code Playgroud)