I have a dataset with 143 data points. I ran a model over it to predict the last 12 data points and I want to display them, together with the confidence interval, in a chart. The problem is that it is not plotting the legend and I want to include it.
The dataset is as follows. Note that several columns are NA until the 131th entry. It happens because these columns only assign values for the prediction
#Define the chart
grafico = ggplot(data=pd,aes(x=date, y=data)) +
geom_line(col='black') + #Real values
geom_line(aes(y=`Point Forecast`), col = 'red') + #Predicted values
geom_ribbon(aes(ymin=`Lo 95`,ymax=`Hi 95`),alpha=.25) + #Confidence interval
scale_x_date(name='Time Period', expand=c(0,0)) + #x label
scale_y_continuous(name='Male kt') + #y label
ggtitle("Male kts - Observed and predicted") +
theme(plot.title = element_text(hjust = 0.5)) #Put the title in the center of the chart
#Plot the chart
grafico
The chart below. The red line is the prediction while the black line is the true value
Does anyone have an idea of how to make it work with legend?