如何组合由自动绘图创建的两个图形?

问题描述

让我们考虑两种金融资产(苹果和黄金):

start <- as.Date("2013-01-01")
end <- as.Date("2016-10-01")
library(quantmod)
library(ggplot2)
getSymbols("AAPL",src = "yahoo",from = start,to = end)
getSymbols("GOLD",to = end)

让我们看看苹果和黄金的图是怎样的:

autoplot(Cl(AAPL))

enter image description here

autoplot(Cl(GOLD))

enter image description here

但是我不知道如何将它们都放在一张图表上。我试图寻找解决方案,但他们都没有使用 autoplot() 函数。在一个坐标系上有两个上述图形是否可行?

我正在寻找类似的东西,但是是用 autoplot()

创建的
ggplot()+geom_line(aes(x = 1:945,y = Cl(AAPL)))+geom_line(aes(x = 1:945,y = Cl(GOLD)))

enter image description here

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)