1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
lexicon2 <- data.frame("Level1" = c(rep("Tox", 9), rep("No tox", 3),rep("safety",3)),
"Level2" = c(rep("Enterobacteria", 6), rep("Bacillus", 5), rep("Probiotic", 4)),
"Level3" = c("E coli", "Proteus", "Citrobacter", "Salmonella", "Shigella", "Yersinia", "B Cereus", "B Anthracis", "B cytotoxicus", "B thuringiensis", "B mycoides", "Bifidobacterium sp"," Lactobacillus casei ", "Lactococcus lactis ", "Strepto. thermophilus")
) |> mutate(Level2=str_c(Level2, "\n",Level3)) |> select(-Level3)
lexicon2 %>%
mutate(top_level = Level1) %>%
pivot_longer(1:2) %>% ##changer car plus que 2 niveaux
group_by(name, value) %>%
mutate(width = n()) %>%ungroup() |>
unique() %>%
arrange(name) %>%
group_by(name) %>%
mutate(ymid = as.numeric(sub("\\D+", "", name)),
ymax = ymid + 0.5, ymin = ymid - 0.5,
xmin = c(0, head(cumsum(width), -1)), ##??
xmax = cumsum(width),
xmid = (xmax + xmin)/2 ) %>%
ggplot(aes(xmid, ymid, fill = top_level)) +
geom_rect(aes(xmin = xmin, xmax = xmax, ymin = ymin, ymax = ymax,
alpha = name, color = top_level)) +
geomtextpath::geom_textpath(aes(y = ymid + 0.25, label = value,
group = value),size=2.5) +
scale_alpha_manual(values = c(1, 0.3, 0.1)) +
scale_fill_manual(values = c("#cd9900", "#00817e","#aaaaaa")) +
scale_colour_manual(values = c("#cd9900", "#00817e","#aaaaaa")) +
scale_y_continuous(limits = c(-0.5, 3.6)) +
coord_polar() +
theme_void() +
theme(legend.position = "none") |
Partager