# Use ade4 with ggplot2

    library(ade4)

    Registered S3 methods overwritten by 'ggpp':
      method                  from
      heightDetails.titleGrob ggplot2
      widthDetails.titleGrob  ggplot2

    data(dunedata)
    acp1 <- dudi.pca(df = dunedata$veg, scannf = FALSE)

## 1 `s.label` with `ggplot2`

    (gg1 <- s_gg.label(acp1$li))

    # Details about layers
    names(gg1$layers)

    [1] "geom_hline" "geom_vline" "geom_label"

### 1.1 Remove the horizontal axis

    gg1$layers$geom_hline <- NULL
    gg1

    names(gg1$layers)

    [1] "geom_vline" "geom_label"

### 1.2 Update axis colors

    gg2 <- s_gg.label(acp1$li)
    gg2$layers$geom_hline$aes_params$colour <- 2 # Horizontal axis in red
    gg2$layers$geom_vline$aes_params$colour <- 3 # Vertical axis in green
    gg2$layers$geom_vline$aes_params$size <- 2 # Vertical axis wider
    gg2

### 1.3 Update labels colors

    gg3 <- s_gg.label(acp1$li)

    # All points in black except numbers 2, 5, 6, 7 and 10 in red
    col1 <- rep(1, 20)
    col1[c(2, 5, 6, 7, 10)] <- rep(2, 5)

    gg3$layers$geom_label$aes_params$colour <- col1
    gg3$layers$geom_label$aes_params$fill <- "lightblue"   # Background color

    gg3

### 1.4 Manage titles (main, subtitle, axis titles)

    library(ggplot2)
    data(banque)
    dudi1 <- dudi.acm(banque, scannf = FALSE)
    ggbanque <- s_gg.label(dudi1$li)
    # Add title and subtitle
    ggbanque + ggplot2::labs(title = "Factorial map from ACM", subtitle = "Here is a subtitle")

    # Remove x-axis title
    ggbanque + ggplot2::labs(x = NULL)

    # Update y-axis title
    ggbanque + ggplot2::labs(y = "My new title for y-axis")

## 2 `s.arrow` with `ggplot2`

    (ga1 <- s_gg.arrow(cbind.data.frame(runif(55,-2,3), runif(55,-3,2))))

    names(ga1$layers)

    [1] "geom_hline"       "geom_vline"       "geom_segment"     "geom_label_repel"

    ga1$layers$geom_hline <- NULL
    ga1$layers$geom_vline <- NULL
    ga1

## 3 `s.class` with `ggplot2`

    xy <- cbind.data.frame(x = runif(200, -1, 1), y = runif(200, -1, 1))
    posi <- factor(xy$x > 0) : factor(xy$y > 0)
    coul <- c("black", "red", "green", "blue")

    s.class(xy, posi)

    gs1 <- s_gg.class(xy, posi) # by default, each level is colored
    gs1

### 3.1 Update colors

    cols <- c("FALSE:TRUE" = "red", "TRUE:TRUE" = "blue", "FALSE:FALSE" = "black", "TRUE:FALSE" = "green")
    gs1 + ggplot2::scale_colour_manual(values = cols)