gpt4 book ai didi

r - 在 quantmod 图表的背景中添加垂直线

转载 作者:行者123 更新时间:2023-12-01 02:02:19 25 4
gpt4 key购买 nike

如何在出现在背景中的 quantmod 中向图表添加垂直线?考虑这个例子:

library(quantmod)
symbol <- "AAPL"
cache <- new.env()
getSymbols(symbol, env=cache)
chartSeries(cache$AAPL, subset="last 3 months")
plot(addLines(v=10)) # Adds vertical line at tick 10.

问题是现在在第 10 个刻度处添加垂直线会隐藏烛台的灯芯:

Hidden candlestick wicks

我也尝试了功能 addVLine来自 qmao .它有效地做到了这一点:
c <- quantmod:::get.current.chob()
i <- index(c@xdata[endpoints(c@xdata, "months")])
plot(addTA(xts(rep(TRUE, length(i)), i), on=-1, col="grey"))

结果如下所示:

enter image description here

虽然我现在在背景中有线条,但它们非常宽且非常突兀。我只是希望它们以网格线已经存在的方式出现在背景中。我怎样才能做到这一点?

注意:这个问题类似于 an existing one ,但在这里我问的是如何在背景中渲染垂直线。

最佳答案

我没有查看源代码来理解为什么会这样,但它似乎可以满足您的需求。基本上,您添加 addLines通过 TA 调用论据 chartSeries .无论如何,这通常是一件好事,因为它避免了为每个 add* 重新绘制图表。称呼。

chartSeries(cache$AAPL, subset="last 3 months", TA="addVo();addLines(v=10,on=-1)")

enter image description here

关于r - 在 quantmod 图表的背景中添加垂直线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35248280/

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