I've tried all day to get a line plot with different line colours and types but now that I managed that, the legend doesn't appear anymore.
The first 10 (of 100) rows of the dataframe:
Duration Clouds 1 2 3 4 5 6 7 8
1 15.00000 51.56604 3.319234 7.479382 6.185313 5.620474 30.149642 5.075788 6.145367 4.779686
2 15.30303 51.56604 3.389524 7.437142 6.146534 5.730071 29.224362 5.127665 6.321472 4.831718
3 15.60606 51.56604 3.461303 7.395140 6.107999 5.841805 28.327479 5.180072 6.502624 4.884316
4 15.90909 51.56604 3.534602 7.353375 6.069705 5.955718 27.458121 5.233015 6.688967 4.937487
5 16.21212 51.56604 3.609453 7.311846 6.031652 6.071852 26.615443 5.286498 6.880650 4.991237
6 16.51515 51.56604 3.685889 7.270552 5.993836 6.190251 25.798626 5.340529 7.077825 5.045572
7 16.81818 51.56604 3.763944 7.229491 5.956258 6.310959 25.006878 5.395111 7.280651 5.100498
8 17.12121 51.56604 3.843652 7.188662 5.918916 6.434020 24.239427 5.450252 7.489290 5.156022
9 17.42424 51.56604 3.925048 7.148063 5.881807 6.559481 23.495530 5.505956 7.703907 5.212151
10 17.72727 51.56604 4.008168 7.107694 5.844932 6.687388 22.774462 5.562229 7.924675 5.268891
And my script to get the plot:
> plot.interact1.2 <- ggplot(pred_df2, aes(x=Duration)) +
+ geom_line(aes(y = `1`), color="#D8C033") +
+ geom_line(aes(y = `2`), color="#B9A2A3") +
+ geom_line(aes(y = `3`), color="#225F6D") +
+ geom_line(aes(y = `4`), color="#B0946F") +
+ geom_line(aes(y = `5`), color="#D8C033", linetype="dashed") +
+ geom_line(aes(y = `6`), color="#B9A2A3", linetype="dashed") +
+ geom_line(aes(y = `7`), color="#225F6D", linetype="dashed") +
+ geom_line(aes(y = `8`), color="#B0946F", linetype="dashed") +
+ scale_color_discrete(name = "Lunar phase", labels = c("New Moon", "Full Moon")) +
+ theme_ipsum() +
+ ylab("Predicted mean values") +
+ xlab("Survey duration")
> plot.interact1.2
I got the scale_color_discrete() as a solution to a similar question from a different post here on stackoverflow but it doesn't seem to help in my situation.