ggplot时间系列,错误:不知道如何自动选择类型为xts/zoo的对象的比例。默认为连续
问题描述:
我是ggplot的新手,虽然这看起来像一个简单的问题,但我很困惑。我收到错误消息ggplot时间系列,错误:不知道如何自动选择类型为xts/zoo的对象的比例。默认为连续
Don't know how to automatically pick scale for object of type xts/zoo. Defaulting to continuous.
而我在图上看不到一条线。下面是输出: 这里是我的代码:
> 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"))
答
动物园提供autoplot.zoo
绘制XTS /动物园对象与GGPLOT2:
autoplot(price, col = I("blue")) + ggtitle("SPY")
还检查了chart_Series
(从quantmod),它采用经典的图形:
chart_Series(SPY)
ggplot likes data.frames。你也需要'ggplot(...)+ geom_line(...)' –