diff --git a/.gitignore b/.gitignore index 65f0e3c..933cdbf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ data/ tmp/ +res/ # ---> R diff --git a/res/Agropyron repens.pdf b/res/Agropyron repens.pdf deleted file mode 100644 index aaa259d..0000000 Binary files a/res/Agropyron repens.pdf and /dev/null differ diff --git a/scripts/main.R b/scripts/main.R index 060c11b..25bf399 100644 --- a/scripts/main.R +++ b/scripts/main.R @@ -20,24 +20,43 @@ source("./scripts/enporzhiañ_kartenn.R") ############################## ## Sevel ur gartenn -anv <- "Agropyron repens" - -sub_data <- data %>% - filter(anv_latin==anv) %>% - tidyr::unite(., label, anv_bzg_1, anv_bzg_2, anv_bzg_3, na.rm=TRUE, sep="\n") +library(ggplot2) +library(ggrepel) -pdf(paste0("./res/", anv, ".pdf"), width=10, height=7) -p <- ggplot(data=kumuniou_poly_simple)+ - geom_sf(size=0.1, color="#bfbfbf")+ - ggtitle(anv)+ - theme_void()+ - # Anvioù - geom_label(data=sub_data, alpha=.25, color="black", aes(x=hed, y=led, label=label))+ - theme(plot.title = element_text(face = "bold", hjust=0.5, size=12), - legend.position="bottom", - legend.title=element_text(size=10), - legend.key.width=unit(0.5, "inches"), - legend.key.height=unit(0.1, "inches")) -print(p) -dev.off() +for(s in unique(data$strollad)) { + #grDevices::cairo_pdf(paste0("./res/strollad_", s, ".pdf"), width=10, height=7, onefile=TRUE) + #pdf(paste0("./res/strollad_", s, ".pdf"), width=10, height=7, onefile=TRUE) + + data_strollad <- data %>% + filter(strollad==s) + + for(anv in unique(data_strollad$anv_latin)) { + grDevices::cairo_pdf(paste0("./res/",s, "_", anv, " (kumuniou).pdf"), width=10, height=7, onefile=TRUE) + sub_data <- data %>% + filter(anv_latin==anv) %>% + tidyr::unite(., label, anv_bzg_1, anv_bzg_2, anv_bzg_3, na.rm=TRUE, sep="\n") + + p <- ggplot(data=kumuniou_poly_simple)+ + geom_sf(size=0.1, color="#bfbfbf")+ + ggtitle(substitute(''~italic(x), list(x=anv)))+ + theme_void()+ + # Pikoù + geom_point(data=sub_data, aes(x=hed, y=led))+ + # Anvioù + geom_label_repel(data=sub_data, color=alpha("black", 1), hjust=0, + nudge_x=0.1, size=4, + aes(x=hed, y=led, label=label))+ + # Neuz + theme(plot.title = element_text(face = "bold", hjust=0.5, size=20), + legend.position="bottom", + legend.title=element_text(size=10), + legend.key.width=unit(0.5, "inches"), + legend.key.height=unit(0.1, "inches")) + + print(p) + dev.off() + } + #dev.off() +} +