From f462e957075cf1f7f96c22a85692d3d2db36dd17 Mon Sep 17 00:00:00 2001
From: Daniel Kalioudjoglou
 <daniel.kalioudjoglou@developpement-durable.gouv.fr>
Date: Tue, 5 Jul 2022 17:29:49 +0200
Subject: [PATCH] mise en page de la publication

modification des cartes 2_2 et 2_7
mis cote a cote les graphes 1_4 et 1_5
rectification de la taille des cartes et graphiques et de la taille des titres des graphs
---
 R/creer_carte_2_2.R                           | 50 ++++++++++++-------
 R/creer_carte_2_7.R                           |  4 +-
 R/creer_graphe_1_4.R                          |  1 +
 .../publication/skeleton/skeleton.Rmd         | 38 ++++++++++++--
 4 files changed, 69 insertions(+), 24 deletions(-)

diff --git a/R/creer_carte_2_2.R b/R/creer_carte_2_2.R
index 0b15122..676aad7 100644
--- a/R/creer_carte_2_2.R
+++ b/R/creer_carte_2_2.R
@@ -12,6 +12,7 @@
 #' @importFrom glue glue
 #' @importFrom sf read_sf st_bbox st_buffer st_crs
 #' @importFrom attempt stop_if stop_if_not
+#' @importFrom mapfactory format_fr
 #'
 #' @export
 #'
@@ -52,28 +53,41 @@ creer_carte_2_2 <- function(millesime_obs_artif) {
 
   carte_2_2 <- ggplot2::ggplot(data) +
     ggplot2::geom_sf(data = monde, fill = "light grey") +
-    ggplot2::geom_sf(fill = "white") +
-    ggplot2::stat_sf_coordinates(ggplot2::aes(
-      size = .data$`total en hectares`,
-      fill = .data$`total en hectares`
-    ),
-    color = "black",
-    shape = 21,
-    alpha = 0.8
-    ) +
-    ggplot2::coord_sf(
-      xlim = c(x_min, x_max),
-      ylim = c(y_min, y_max),
-      expand = FALSE,
-      crs = sf::st_crs(data),
-      datum = NA
-    ) +
+    # carte modifiee
+    # ggplot2::geom_sf(ggplot2::aes(fill= .data$`total en hectares`),
+    #                  color = "black")+
+    ggplot2::geom_sf(ggplot2::aes(fill= .data$`total en hectares`))+
+      ggplot2::coord_sf(
+    xlim = c(x_min, x_max),
+    ylim = c(y_min, y_max),
+    expand = FALSE,
+    crs = sf::st_crs(data),
+    datum = NA
+  ) +
+
+
+    # ggplot2::geom_sf(fill = "white") +
+    # ggplot2::stat_sf_coordinates(ggplot2::aes(
+    #   size = .data$`total en hectares`,
+    #   fill = .data$`total en hectares`
+    # ),
+    # color = "black",
+    # shape = 21,
+    # alpha = 0.8
+    # ) +
+    # ggplot2::coord_sf(
+    #   xlim = c(x_min, x_max),
+    #   ylim = c(y_min, y_max),
+    #   expand = FALSE,
+    #   crs = sf::st_crs(data),
+    #   datum = NA
+    # ) +
     ggplot2::theme(
       panel.background = ggplot2::element_rect(fill = "light blue")
     ) +
-    gouvdown::scale_fill_gouv_continuous(palette = "pal_gouv_h", reverse = TRUE, name = "", labels = function(x) format_fr(x, dec = 0)) +
+    gouvdown::scale_fill_gouv_continuous(palette = "pal_gouv_h", reverse = TRUE, name = "", labels = function(x) mapfactory::format_fr(x, dec = 0)) +
     # ggplot2::scale_size_area(name="")+
-    ggplot2::scale_size_continuous(range = c(0, 20), labels = function(x) format_fr(x, dec = 0)) +
+    ggplot2::scale_size_continuous(range = c(0, 20), labels = function(x) mapfactory::format_fr(x, dec = 0)) +
     ggplot2::labs(
       title = glue::glue("Nouvelles surfaces consomm\u00e9es entre {millesime_debut} et {millesime_fin} (10 ans)"),
       subtitle = "",
diff --git a/R/creer_carte_2_7.R b/R/creer_carte_2_7.R
index f73cdb7..262cd5a 100644
--- a/R/creer_carte_2_7.R
+++ b/R/creer_carte_2_7.R
@@ -52,7 +52,9 @@ creer_carte_2_7 <- function(millesime_obs_artif= NULL, code_reg = NULL) {
     dplyr::pull(.data$NCCENR)
 
   fond_cartographique <- mapfactory::fond_carto(nom_reg = nom_region)
-  bins  <- stats::quantile(data$valeur,probs = c(0,0.1, 0.25, 0.5,0.75,0.9,1),na.rm=TRUE)
+  # bins  <- stats::quantile(data$valeur,probs = c(0,0.1, 0.25, 0.5,0.75,0.9,1),na.rm=TRUE)
+  bins  <- stats::quantile(data$valeur,probs = c(0,0.2, 0.4, 0.6,0.8,1),na.rm=TRUE)
+
 
   carte_2_7 <- mapfactory::creer_carte_communes(data = data,
                                                 code_region=code_reg,
diff --git a/R/creer_graphe_1_4.R b/R/creer_graphe_1_4.R
index 23e5029..2a89401 100644
--- a/R/creer_graphe_1_4.R
+++ b/R/creer_graphe_1_4.R
@@ -42,6 +42,7 @@ creer_graphe_1_4 <- function(millesime_teruti, code_reg){
     COGiter::filtrer_cog(reg = code_reg) %>%
     dplyr::filter(.data$TypeZone == "D\u00e9partements",
                   .data$date == lubridate::make_date(millesime_teruti,"01","01")) %>%
+    # dplyr::filter(.data$date == lubridate::make_date(millesime_teruti,"01","01")) %>%
     tidyr::spread(key=.data$variable,value=.data$valeur,fill=0) %>%
     tricky::set_standard_names() %>%
     dplyr::arrange(.data$typezone,.data$zone) %>%
diff --git a/inst/rmarkdown/templates/publication/skeleton/skeleton.Rmd b/inst/rmarkdown/templates/publication/skeleton/skeleton.Rmd
index ad093b6..5c77a81 100644
--- a/inst/rmarkdown/templates/publication/skeleton/skeleton.Rmd
+++ b/inst/rmarkdown/templates/publication/skeleton/skeleton.Rmd
@@ -34,6 +34,10 @@ texte d'introduction...
 texte......
 
 ```{r diag barres taux artificialisation par region}
+ggplot2::theme_set(ggplot2::theme_minimal() +
+                     ggplot2::theme(plot.caption.position =  "plot",
+                                    plot.title.position = "plot",
+                   plot.title = ggplot2::element_text(size = 14)))
 creer_graphe_1_1(millesime_teruti = params$millesime_teruti,
                  code_reg = params$code_reg )
 ```
@@ -54,18 +58,25 @@ creer_carte_1_3(millesime_ocsge = params$millesime_ocsge,
 
 texte......
 
+<div class = "row">
+<div class = "col-md-6">
+
 ```{r graph surfaces artificialisees en volume}
 creer_graphe_1_4(millesime_teruti = params$millesime_teruti,
                  code_reg = params$code_reg)
 ```
 
-texte...
+</div>
+<div class = "col-md-6">
+
 
 ```{r graph part surfaces artificialisees}
 
 creer_graphe_1_5(millesime_teruti = params$millesime_teruti,
                 code_reg = params$code_reg)
 ```
+</div>
+</div>
 
 texte...
 
@@ -75,6 +86,7 @@ creer_graphe_1_6(millesime_ocsge = params$millesime_ocsge,
                  millesime_population = params$millesime_population,
                  code_reg = params$code_reg)
 ```
+
 texte...
 
 ```{r tableau artificialisation OCSGE}
@@ -103,7 +115,7 @@ creer_graphe_2_3(millesime_obs_artif = params$millesime_obs_artif,
 
 ```
 
-```{r graph conso espace departements 10 ans,fig.width=5,fig.height=7}
+```{r graph conso espace departements 10 ans,fig.width=7,fig.height=7}
 creer_graphe_2_4(millesime_obs_artif = params$millesime_obs_artif, 
                  code_reg = params$code_reg )
 ```
@@ -139,7 +151,11 @@ creer_graphe_3_1(millesime_stock_artif = params$millesime_stock_artif,
                  millesime_population = params$millesime_population, 
                  code_reg = params$code_reg)
 ```
-```{r carte communale de l etalement urbain,fig.width=12,fig.height=8}
+```{r carte communale de l etalement urbain,fig.width=9,fig.height=7}
+ggplot2::theme_set(ggplot2::theme_minimal() +
+                     ggplot2::theme(plot.caption.position =  "plot",
+                                    plot.title.position = "plot",
+                   plot.title = ggplot2::element_text(size = 14)))
 creer_carte_3_2(millesime_etalement_urbain = params$millesime_etalement_urbain, 
                  police_annotation = "Marianne",
                  code_reg = params$code_reg )
@@ -147,6 +163,10 @@ creer_carte_3_2(millesime_etalement_urbain = params$millesime_etalement_urbain,
 
 
 ```{r graph croissance comparee population artificialisation,fig.width=9,fig.height=7}
+ggplot2::theme_set(ggplot2::theme_minimal() +
+                     ggplot2::theme(plot.caption.position =  "plot",
+                                    plot.title.position = "plot",
+                   plot.title = ggplot2::element_text(size = 14)))
 creer_graphe_3_3(millesime_stock_artif = params$millesime_stock_artif,
                  millesime_population = params$millesime_population,
                  code_reg = params$code_reg)
@@ -156,12 +176,20 @@ creer_graphe_3_3(millesime_stock_artif = params$millesime_stock_artif,
 
 
 ```{r graph surfaces artificialisees par habitant,fig.width=9,fig.height=7}
+ggplot2::theme_set(ggplot2::theme_minimal() +
+                     ggplot2::theme(plot.caption.position =  "plot",
+                                    plot.title.position = "plot",
+                   plot.title = ggplot2::element_text(size = 14)))
 creer_graphe_3_4(millesime_stock_artif = params$millesime_stock_artif,
                  millesime_population = params$millesime_population,
                  code_reg = params$code_reg)
 ```
 
 ```{r graph surfaces artificialisees par habitant par type territoire,fig.width=9,fig.height=7}
+ggplot2::theme_set(ggplot2::theme_minimal() +
+                     ggplot2::theme(plot.caption.position =  "plot",
+                                    plot.title.position = "plot",
+                   plot.title = ggplot2::element_text(size = 14)))
 creer_graphe_4_2(millesime_stock_artif = params$millesime_stock_artif,
                  millesime_population = params$millesime_population,
                  code_reg = params$code_reg)
@@ -174,8 +202,8 @@ creer_graphe_4_2(millesime_stock_artif = params$millesime_stock_artif,
 #### Et si l'artificialisation se poursuivait...
 
 ```{r creer_graphe_5_1, fig.height=2.5,fig.width=8}
-creer_graphe_5_1(millesime_stock_artif = params$millesime_stock_artif,
-                 code_reg = params$code_reg)
+# creer_graphe_5_1(millesime_stock_artif = params$millesime_stock_artif,
+#                  code_reg = params$code_reg)
 ```
 
 #### Quel développement sans objectif de réduction de la consommation d'espace ?
-- 
GitLab