Can't plot my time series data and training data on the same graph, with different colours?

130 views Asked by At

Im trying to plot both the original data and my training data on the same graph with this code:

timeseries <- ts(df$new_cases_per_million, start=c(2021,2), end=c(2022,3), frequency=52)
ts_train <- window(timeseries,start=c(2021,2),end=c(2022,3))
ts_test  <- window(timeseries,start=c(2022,3))

autoplot(ts_train3,xlab="Year",series="ts_train3") + 
  autolayer(ts_test3,series = "Test set3") +
  ggtitle("timeseries plot")

However when I execute this code, the graph only plots the original data, and not my trained data: enter image description here

I also get this error with my plot:

geom_path: Each group consists of only one observation. Do you need to adjust the group aesthetic?

I want it to look something like this: plot with original data and training data

0

There are 0 answers