Hi community
I'm try to add the geom_vline() legend, the vertical line in the plot, but I didn't could.
Try for many way but was impossible. Maybe the problem is because I'm other DF for make this line.
If exits other form for make this plot is very well welcome. Because Im a little confused about this legend.
data: df_.xlsx - Google Sheets
library(readxl)
library(tidyverse)
library(hrbrthemes)
library(lubridate)
df_<- read.excell('path')
T1_data_nor7 <- structure(list(DATE = structure(c(19353, 19353, 19353, 19361, 19360),
class = "Date"),
Treatment = c("T1", "T2", "T3", "T4", "T2"),
Accession = c("BEAN2", "BEAN2", "BEAN2", "BEAN2", "BEAN1"),
Flower_number = c(1, 2, 1, 1, 3), agregar_vline = c(TRUE, TRUE, TRUE, TRUE, TRUE)),
class = c("grouped_df", "tbl_df", "tbl","data.frame"), row.names = c(NA, -5L),
groups = structure(list(DATE = structure(c(19353, 19353, 19353, 19360, 19361), class = "Date"),
Accession = c("BEAN2", "BEAN2", "BEAN2", "BEAN1", "BEAN2"),
Treatment = c("T1", "T2", "T3", "T2", "T4"),
.rows = structure(list(1L, 2L, 3L, 5L, 4L), ptype = integer(0), class = c("vctrs_list_of", "vctrs_vctr", "list"))), class = c("tbl_df", "tbl", "data.frame"),
row.names = c(NA, -5L), .drop = TRUE))
ggplot(df_) +
geom_line(aes(DATE, value, color = name, fill=Treatment))+
theme_ipsum()+
scale_color_manual(values = c('#FF3900','#1E11C4','#0BDA00'))+
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1,size = 10),
axis.text.y = element_text(size = 9),
panel.border = element_rect(colour = "#1D1504", fill = NA),
panel.background = element_rect(fill = '#F9FBE6', colour = 'red'),
legend.position = 'bottom')+
scale_x_date(date_breaks = "2 day", date_minor_breaks = "2 day",
date_labels = "%d-%b")+
labs(title='BEANS Heat Accumulation',
y='Heat Accumulation') +
facet_wrap(.~Accession +Treatment, scales = 'free_y') +
geom_vline(data =T1_data_nor7[T1_data_nor7$agregar_vline, ],
aes (xintercept = DATE) , linetype =1, size= 0.8,
color='#D1008D')
The idea is add the line legend with this color '#D1008D'.