gpt4 book ai didi

r - 向 xts 图中添加点

转载 作者:行者123 更新时间:2023-12-04 22:50:27 25 4
gpt4 key购买 nike

我以为Adding Points, Legends and Text to plots using xts objects会有这个问题的答案,但显然不是......

require(quantmod)
getSymbols("SAM")
big.red.dot <- zoo(85, as.Date("2011-05-05"))
plot(SAM['2011'])
points( big.red.dot, col="red", pch=19, cex=5 )

这个好像是直接从教科书里出来的。 ?plot.zoo不包含任何带有 point() 的示例尽管。

最佳答案

默认情况下,quantmod::getSymbols 创建的对象实际上是类(class) xts .这意味着您的 big.red.dot应该是 xts目的:

big.red.dot <- xts(85, as.Date("2011-05-05"))
plot(SAM['2011'])
points( big.red.dot, col="red", pch=19, cex=5 )

enter image description here

关于r - 向 xts 图中添加点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7303986/

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