首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在quantmod::chart_Series()中使用xlim/ylim或xrange/yrange覆盖y-scale和x-scale -不可能吗?

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

Stack Overflow用户
提问于 2012-06-20 03:42:16
回答 1查看 1.2K关注 0票数 5

我试图在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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-06-20 04:46:56

chart_Series()的帮助页面--三次!--说明它是实验性的,所以可能最终的改进版本会有很好的句柄来设置这些限制。

在此之前,这里有一个黑客攻击(?)这将允许您设置限制,可能会教您一些关于chart_Series()如何工作的知识(例如,通过创建"replot"类的环境/闭包,该类存储了创建图表所需的所有信息)。

代码语言:javascript
运行
复制
## 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
票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11108206

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档