-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot-individuals-dendro.Rmd
57 lines (46 loc) · 1.79 KB
/
plot-individuals-dendro.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
Import libs and define global vars
```{r}
source("lib-dendro.R")
library(ggplot2)
library(dplyr)
### DEFINE GLOBAL VARS ###
PATH = '/home/akronix/workspace/dendro';
setwd(PATH)
DATA_DIR = 'processed/Penaflor-processed'
# lentiscos = c(92223485, 92232435, 92232429, 92232425, 92232432)
# sabinas = c(92232422, 92232436, 92232430, 92232434, 92232433, 92232427, 92232428, 92232431, 92232426)
TreeList <- read.table("TreeList.txt",header=T)
Qi = TreeList %>% filter(class == "Quercus") %>% pull(series)
P_D = TreeList %>% filter(class == "D") %>% pull(series)
P_ND = TreeList %>% filter(class == "ND") %>% pull(series)
```
Define plot functions
```{r}
plot_line<- function(data, title, y = data$value) {
ggplot(data = data, aes(x=ts, y=y )) +
ggtitle(title) +
geom_line() +
#geom_line( aes (linetype = "Quercus Ilex"), col='darkgreen', show.legend = F) +
labs(x=expression(''),
y=expression(Delta*" D (um)"))+
theme_bw() +
geom_hline(yintercept=0,lty=2,linewidth=0.2)+
#facet_grid(class~.,scales = "free_y")+
scale_x_datetime(date_breaks = "1 month", date_labels="%b %Y") +
theme(axis.text.x = element_text(angle = 30, hjust=1))
}
```
Read data and plot it one by one and save it to a pdf file
```{r}
list_files <- list.files(file.path(".",DATA_DIR), pattern="*.csv$", full.names=TRUE)
pdf("dendrometers_Penaflor_plots.pdf", onefile = TRUE)
for (dendro.fn in list_files) {
dendro.db <- read.one.processed(dendro.fn)
if (first(dendro.db$series) %in% Qi) specie = "Quercus"
else if(first(dendro.db$series) %in% P_D) specie = "Declining Pine"
else if(first(dendro.db$series) %in% P_ND) specie = "Non-Declining Pine"
# ifelse(dendro.db$series %in% lentiscos, "Pistacia Lentiscus", "Juniperus Phoenicea")
print(plot_line(dendro.db, paste(dendro.db$series, '-', specie)))
}
dev.off()
```