# Pingouins -------------------------------------------------------
library(tidyverse)
## Warning: le package 'readr' a été compilé avec la version R 4.4.2
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.5.1 ✔ tibble 3.2.1
## ✔ lubridate 1.9.3 ✔ tidyr 1.3.1
## ✔ purrr 1.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(palmerpenguins)
## Warning: le package 'palmerpenguins' a été compilé avec la version R 4.4.2
library(ggplot2)
library(ggimage)
## Warning: le package 'ggimage' a été compilé avec la version R 4.4.3
library(dplyr)
library(grid)
library(gganimate)
## Warning: le package 'gganimate' a été compilé avec la version R 4.4.3
data("penguins")
# Graphique principal
p <- ggplot(penguins %>% filter(!is.na(body_mass_g)),
aes(x = body_mass_g, y = species, color = island)) +
geom_jitter(size = 2, alpha = 0.8) +
scale_color_manual(values = c("Biscoe" = "green", "Dream" = "deepskyblue", "Torgersen" = "gold")) +
theme_minimal()+
labs(
title = "Répartition de la masse corporelle des manchots selon l'espèce",
subtitle = "Chaque point représente un individu, coloré selon son île d’origine.",
x = "Masse corporelle", y = "Espèce",
color = "Îles d'habitat",
caption = "Source : Gorman et Al, 2020. Données palmerpenguins. DM2 DES Info-Com. Léa Blondeau - 20/04/2025"
)
#Télécharger photos
image_path <- "1. DM2 VISUALISATION/Adelie.jpg"
image_path <- "1. DM2 VISUALISATION/Gentoo.jpg"
image_path <- "1. DM2 VISUALISATION/Chinstrap.jpg"
plot <- penguins %>%
mutate(img = image_path)
image_data <- data.frame(
x = c(6000, 6100, 2800),
y = c("Adelie", "Chinstrap", "Gentoo"),
image = c("Adelie.jpg", "Chinstrap.jpg", "Gentoo.jpg")
)
p <- p +
geom_image(data = image_data, aes(x = x, y = y, image = image), size = 0.1, inherit.aes = FALSE)
arrow_data <- data.frame(
x = c(5400, 5600, 3300),
y = c("Adelie", "Chinstrap", "Gentoo"),
xend = c(4800, 4600, 4000),
yend = c("Adelie", "Chinstrap", "Gentoo")
)
p <- p +
geom_segment(data = arrow_data,
aes(x = x, y = y, xend = xend, yend = yend),
arrow = arrow(length = unit(0.2, "cm")),
color = "black", inherit.aes = FALSE)
text_data <- data.frame(
x = c(5600, 5800, 3100),
y = c("Adelie", "Chinstrap", "Gentoo"),
label = c("Île Biscoe\nÎle Dream\nÎle Torgersen", "Île Dream", "Île Biscoe")
)
p <- p +
geom_text(data = text_data, aes(x = x, y = y, label = label),
fontface = "bold", size = 4, inherit.aes = FALSE)
p + labs(
title = "Répartition de la masse corporelle des manchots selon l'espèce",
subtitle = "Chaque point représente un individu, coloré selon son île d’origine.",
x = "Masse corporelle", y = "Espèce",
color = "Îles d'habitat",
caption = "Source : Gorman et Al, 2020. Données palmerpenguins. DM2 DES Info-Com. Léa Blondeau - 20/04/2025"
)

ggsave("manchots_graphique_Léa.png", plot = p, width = 12, height = 7, dpi = 300)