gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 18:47:55 25 4
gpt4 key购买 nike

我试图在 quantmod::chart_Series() 之上绘制一些支撑/阻力线。问题是有趣的支撑/阻力线超出(低于或高于)直到当前时间的系列数据范围(我还想将图表向右扩展到超出数据的最后一个时间戳)。

查看 quantmod::chart_Series() 的源代码,我看不到指定 ylim/xlim 的方法,或者在“过去”使用 quantmod::chartSeries 使用 yrange 覆盖 y 比例尺时可能发生的情况。在这里发表评论 https://r-forge.r-project.org/scm/viewvc.php?view=rev&root=quantmod&revision=520也证实了我的预感...

我的诊断是否正确,或者是否有一种方法可以在 quantmod::chart_Series 中启用 y 尺度覆盖?任何想法如何做我想要的高度赞赏。

谢谢。

最好的事物,
萨摩

最佳答案

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

关于r - 在 quantmod::chart_Series() 中使用 xlim/ylim 或 xrange/yrange 覆盖 y-scale 和 x-scale - 不可能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11108206/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com