It's a minor issue but one of the rectangles showed in the legend ("Intrusión de polvo sahariano") has its border colour mistaken, instead of orange its border is grey.
This what I've donde. Thanks in advance.
data1 <- timeAverage(Calibración, avg.time= "day")
data2 <- data1 %>% pivot_longer(c("ScatRed3000","ScatGreen3000","ScatBlue3000"),
names_to= "Scat3000", values_to= "Scat3000V") %>% print()
p <-ggplot() +
geom_line(data=data2, aes(x= date, y= Scat3000V, colour= Scat3000),lty=1,lwd=1) +
geom_rect(aes(xmin= ymd_hms("2023-02-15 21:45:00"), xmax= ymd_hms("2023-02-22 23:55:00"),
ymin= +Inf, ymax= -Inf, fill= "Intrusión de polvo sahariano"), colour= "orange", alpha= 0.3, lwd=1) +
geom_rect(aes(xmin= ymd_hms("2023-01-18 00:00:00"), xmax= ymd_hms("2023-01-21 00:00:00"),
ymin= +Inf, ymax= -Inf, fill= "NA"), colour= "grey", alpha= 0.5, lwd=1) +
geom_rect(aes(xmin= ymd_hms("2023-02-03 00:00:00"), xmax= ymd_hms("2023-02-06 00:00:00"),
ymin= +Inf, ymax= -Inf, fill= "NA"), colour= "grey", alpha= 0.5, lwd=1) +
scale_fill_manual("", breaks=c("Intrusión de polvo sahariano","NA") , values=c("chocolate1","grey")) +
scale_colour_manual(values= c("blue","green","red"), labels=c("450 nm","525 nm","635 nm")) +
scale_x_datetime(labels= date_format("%b%d"), date_breaks = "2 day") +
labs(x="") + labs(y= expression("Dispersión Aurora 3000 (Mm"^-1*")")) + labs(colour="") + labs(title= "Dispersión Aurora 3000 VS Días") +
theme(axis.title.x= element_text(size=0)) +
theme(plot.title= element_text(hjust= 0.5, size= 13)) +
theme(axis.title.y= element_text(size= 11)) +
theme(legend.position= "right") +
theme_bw()
data3 <- data1 %>% pivot_longer(c("ScatRed4000","ScatGreen4000","ScatBlue4000"),
names_to= "Scat4000", values_to= "Scat4000V") %>% print()
q <-ggplot() +
geom_line(data=data3, aes(x= date, y= Scat4000V, colour= Scat4000),lty=1,lwd=1) +
geom_rect(aes(xmin= ymd_hms("2023-02-15 21:45:00"), xmax= ymd_hms("2023-02-22 23:55:00"),
ymin= +Inf, ymax= -Inf, fill= "Intrusión de polvo sahariano"), colour= "orange", alpha= 0.3, lwd= 1) +
geom_rect(aes(xmin= ymd_hms("2023-01-18 00:00:00"), xmax= ymd_hms("2023-01-21 00:00:00"),
ymin= +Inf, ymax= -Inf, fill= "NA"), colour= "grey", alpha= 0.5, lwd=1) +
geom_rect(aes(xmin= ymd_hms("2023-02-03 00:00:00"), xmax= ymd_hms("2023-02-06 00:00:00"),
ymin= +Inf, ymax= -Inf, fill= "NA"), colour= "grey", alpha= 0.5, lwd=1) +
scale_fill_manual("", breaks=c("Intrusión de polvo sahariano","NA"), values=c("chocolate1","grey")) +
scale_colour_manual(values= c("blue","green","red"), labels=c("450 nm","525 nm","635 nm")) +
scale_x_datetime(labels= date_format("%b%d"), date_breaks = "2 day") +
labs(x="") + labs(y= expression("Dispersión Aurora 4000 (Mm"^-1*")")) + labs(colour="") + labs(title= "Dispersión Aurora 4000 VS Días") +
theme(axis.title.x= element_text(size=0)) +
theme(plot.title= element_text(hjust= 0.5, size= 13)) +
theme(axis.title.y= element_text(size= 11)) +
theme(legend.position= "right") +
theme_bw()
plot_grid(p,q,ncol= 1, nrow= 2, rel_widths=c(1,1),
labels=c("a)","b)"))
And this is the graph: Graph