Вот заголовок данных:
LocationName Section Event_Date Year Species_Code Area YOYpop ADTpop TOTpop YOYmnwt ADTmnwt
<chr> <chr> <dttm> <dbl> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 Cosby Creek 2 2013-06-04 00:00:00 2013 BKT 410 9 73 82 2.8 25.3
2 Cosby Creek 2 2014-06-03 00:00:00 2014 BKT 693. 62 34 92 1.7 36.1
3 Cosby Creek 2 2015-06-12 00:00:00 2015 BKT 454. 63 46 109 2.3 28.4
4 Cosby Creek 2 2016-06-13 00:00:00 2016 BKT 506. 20 56 76 3.2 30.2
5 Cosby Creek 2 2017-06-12 00:00:00 2017 BKT 442. 13 19 32 6.2 45.3
6 Cosby Creek 2 2000-06-01 00:00:00 2000 BKT 563. 33 37 72 3 32.5
Вот код:
library(tidyverse)
select(Year, YOYBiom, ADTBiom) %>%
gather(key = Age, value = Biomass, YOYBiom, ADTBiom)
ggplot(FISH.biom, aes(x = Year, y = Biomass)) +
geom_point(aes(colour = Age)) +
scale_colour_manual(values = c("orange", "blue")) +
geom_hline(aes(yintercept = c(quantile(FISH$YOYBiom, 0.025)), linetype = "YOY Lower CL"), colour = "blue") +
geom_hline(aes(yintercept = c(quantile(FISH$YOYBiom, 0.975)), linetype = "YOY Upper CL"), colour = "blue") +
geom_hline(aes(yintercept = c(quantile(FISH$ADTBiom, 0.025)), linetype = "ADT Lower CL"), colour = "orange") +
geom_hline(aes(yintercept = c(quantile(FISH$ADTBiom, 0.975)), linetype = "ADT Upper CL"), colour = "orange") +
labs(title = "Annual Biomass", subtitle = "(Cosby Creek)", x = "Year", y = "Biomass (kg/ha)")+ #adds labels
theme_bw(base_size = 10)
Вот выходной график:
![enter image description here](https://i.stack.imgur.com/UvzPK.png)
Как видите, есть пара вопросов. Я ищу:
- Цвета в легенде для
geom_hline
соответствуют тому, что они есть на графике
- заменить заголовок / метку легенды для geom_hline чем-то более значимым вместо 'linetype'
Я нашел помощь здесь: Как добавить легенду в хлайн?
Но я ударился о стену.
Спасибо,