reprex:
library(tidyverse)
df <- tibble::tibble(
epoca = factor(c("H", "S", "S", "H", "S", "H", "S"), levels = c("S", "H")),
ano = c("2019", "2018", "2019", "2021", "2022", "2022", "2021"),
n = rep(3:1, c(3L, 2L, 2L)),
etiqueta = rep(c("3", "2", "1"), c(3L, 2L, 2L)),
ffvv = c(rep("a", 3), rep("b", 4))
)
df %>%
ggplot(aes(x = epoca, y = n, fill = epoca)) +
geom_col(width = 0.8, position = position_dodge(0.8)) +
geom_text(aes(x = epoca, label = etiqueta),
position = position_dodge(0.9), vjust = 0, size = 8) +
ggh4x::facet_nested(cols = vars(ffvv, ano),
switch = "x",
scales = "free_x",
space = "free_x") +
theme(strip.background = element_rect(fill = "white"),
strip.text = element_text(size = 25, lineheight = 0.6),
strip.placement = "outside",
axis.text.x = element_text(angle = 0, size = 27, lineheight = unit(.8, "lines")))