我正在使用新的chart_Series
和add_TA
相当多的。它对我来说效果很好,我发现它非常有用。
我正在尝试在图表上添加一些东西(水平线和一些文本)。这里开始出现问题。正确绘制水平线和文本后,如果我调用后续操作,它们就会消失add_TA
...请参阅下面的示例代码,该示例代码重现了该问题:
library(quantmod)
getSymbols("SPY")
dev.new()
chart_Series(SPY)
add_TA(ADX(HLC(SPY))$ADX)
abline(h=15, col="red")
abline(h=35, col="green")
text(10, 7, "Text and horizontal lines disappear after next add_TA is called",
col="blue", cex=0.8, adj = c(0,0))
# run the code up to this point (including text(...
# see how horizontal lines drawn with abline and text is displayed correctly
# now run the last line by adding additional TA and you will see that lines
# and text disappears
add_TA(DVI(Cl(SPY))$dvi)
这是预期的行为吗?
编辑:如何使这项工作(根据下面的 Joshua 评论:在重绘绘图对象(chob)时重绘线条和文本)?