Let's say I have the following dataset and generate the subsequent plot:
df <- data.frame(date=seq.Date(as.Date('2023-01-01'), as.Date('2023-05-01'), by='month'),
baseline=rnorm(5), bad_economy=rnorm(5), good_economy=rnorm(5))
p <- ggplot(df, aes(x=date)) +
geom_line(aes(y=baseline, color='Baseline')) +
geom_line(aes(y=bad_economy, color='Bad Economy')) +
geom_line(aes(y=good_economy, color='Good Economy'))
This results in the following plot:
In the legend of the plot, I would like 'Baseline' to be first. How can I do this? The examples I've seen all require modifying the data to use a factor variable to identify colour. Is there a way I can change the order without having to do that?