![](/img/trans.png)
[英]R quantmod chartSeries: Add multiple TA overlay to single chart
[英]R quantmod chartSeries: Add two time series to chart
使用 Quantmod 的 chartSeries 和 chart_Series 函数,我一直试图在一个图表上绘制两个时间序列。 以下代码导致图表输出中出现一条粗绿带。 我知道这是因为我正在绑定它并为每个观察显示两个值。 但是,我无法弄清楚如何分别显示两个时间序列。
如果使用 Quantmod 函数无法做到这一点,是否可以在 ggplot 中做到这一点?
library(quantmod)
getSymbols(c('VXX','^VIX'), from = "2019-01-01", to = "2020-03-16")
symbols <- c(VIX$VIX.Adjusted,VXX$VXX.Adjusted)
chartSeries(symbols)
有迹象表明,使它比使用更容易一点了几包chartSeries
从quantmod。
包 rtsplot。 使用基本 R 绘图函数绘制时间序列。 阅读帮助 pdf 了解所有选项。
library(rtsplot)
rtsplot(VIX)
rtsplot.lines(VXX$VXX.Adjusted)
或者如果你想使用 ggplot2,你可以使用 tidyquant。 tidyquant 还向 ggplot2 添加了烛台图表选项。 阅读小插图以获取更多信息:
library(tidyquant)
library(ggplot2)
vols <- tq_get(c('VXX','^VIX'), from = "2019-01-01", to = "2020-03-16")
vols %>%
ggplot(aes(x = date, y = adjusted, group = symbol)) +
geom_line() +
theme_tq()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.