2017-10-12 43 views
0

我是ggplot的新手,虽然这看起来像一个简单的问题,但我很困惑。我收到错误消息ggplot时间系列,错误:不知道如何自动选择类型为xts/zoo的对象的比例。默认为连续

Don't know how to automatically pick scale for object of type xts/zoo. Defaulting to continuous.

而我在图上看不到一条线。下面是输出: 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

ggplot likes data.frames。你也需要'ggplot(...)+ geom_line(...)' –

回答

0

动物园提供autoplot.zoo绘制XTS /动物园对象与GGPLOT2:

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

还检查了chart_Series(从quantmod),它采用经典的图形:

chart_Series(SPY) 
相关问题