R/graph_evol.R

Defines functions graph_evol

Documented in graph_evol

#' Fonction de graph
#'
#' @param data les donnees filtrees
#' @param ind indicateur a mapper
#' @param nom_ind nom de l'indicateur
#' @param lim_inf borne inferieure du graph
#' @param lim_sup borne superieure du graph
#' @param vector_col le vecteur de couleur
#' @param vector_nom le vecteur de noms
#'
#' @return un graph
#' @export
#'
graph_evol <-
  function(data,
           ind,
           nom_ind,
           lim_inf,
           lim_sup,
           vector_col,
           vector_nom) {
    ind <- enquo(ind)
    
    data %>%
      mutate(annee = as.numeric(annee)) %>%
      ggplot(aes(
        x = annee,
        y = !!ind,
        group = fap87,
        color = fap87
      )) +
      geom_line(lwd = 1.2) +
      labs(title = nom_ind) +
      scale_x_continuous(name = "", breaks = seq(2011, 2018, 1)) +
      scale_y_continuous(
        name = "",
        limits = c(lim_inf, lim_sup),
        breaks = seq(-10, 10, 0.5)
      ) +
      scale_color_manual(name = "",
                         values = vector_col,
                         labels = vector_nom) +
      theme_minimal() +
      theme(
        text = element_text(size = 14,
                            color = "#636362"),
        title = element_text(face = "bold", size = 14),
        panel.grid.minor = element_blank()
      )
  }
tvroylandt/gravitype documentation built on Feb. 7, 2020, 2:37 a.m.