我正在尝试将图像叠加在预测图上。预测对象似乎没有
library(quantmod)
Stock_df<-as.data.frame(getSymbols(Symbols = "AAPL", src = "yahoo", from = "2017-05-06", env = NULL))
fit <- auto.arima(Stock_df$AAPL.Close,ic="bic")
fit.forecast <- forecast(fit)
library(jpeg)
my_image=readJPEG("Myimage.jpg")
plot.new()
lim <- par()
rasterImage(my_image, lim$usr[1], lim$usr[3], lim$usr[2], lim$usr[4], main= "AAPL")
line(fit.forecast)
我收到以下错误消息:
Error in xy.coords(x, y, setLab = FALSE) :
'x' is a list, but does not have components 'x' and 'y'
如何简单地在图像上叠加预测对象?
解
经过一些试验和错误以及一些研究。我找到了以下解决方案。plot.new()
lim <- par()
rasterImage(my_image, lim$usr[1], lim$usr[3], lim$usr[2], lim$usr[4], main= "AAPL")
par(new=TRUE)
plot(fit.forecast)
我希望这个解决方案有帮助