首页 文章

ggplot时间序列,错误:不知道如何自动为xts / zoo类型的对象选择比例 . 违约持续

提问于
浏览
0

我是ggplot的新手,虽然这看起来像一个简单的问题,但我很困惑 . 我收到错误消息

不知道如何自动选择xts / zoo类型的对象的比例 . 违约持续 .

我输出了't see a line on my graph. Here':
ggplot output
这是我的代码:

> library(quantmod)
> library(TTR)
> library(ggplot2)
> getSymbols("SPY")
[1] "SPY"
> price<-SPY[,1]
> ggplot(price,aes(x=time(price),y=price),geom_line(color="blue"))

1 回答

  • 0

    zoo提供 autoplot.zoo 用ggplot2绘制xts / zoo对象:

    autoplot(price, col = I("blue")) + ggtitle("SPY")
    

    另请查看使用经典图形的 chart_Series (来自quantmod):

    chart_Series(SPY)
    

相关问题