2017-10-12 89 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) 
相關問題