Víctor Gauto
  • Tidytuesday
  • Publicaciones
  • Mapas de Argentina
  • Visualizaciones
  • Mi CV
  1. 2025
  2. Semana 41

Sitio en construcción

  • Inicio
  • 2025
    • Semana 02
    • Semana 03
    • Semana 04
    • Semana 05
    • Semana 06
    • Semana 07
    • Semana 08
    • Semana 09
    • Semana 10
    • Semana 11
    • Semana 12
    • Semana 13
    • Semana 14
    • Semana 15
    • Semana 16
    • Semana 17
    • Semana 18
    • Semana 19
    • Semana 20
    • Semana 21
    • Semana 22
    • Semana 23
    • Semana 24
    • Semana 25
    • Semana 26
    • Semana 27
    • Semana 28
    • Semana 29
    • Semana 30
    • Semana 31
    • Semana 32
    • Semana 33
    • Semana 34
    • Semana 35
    • Semana 36
    • Semana 37
    • Semana 38
    • Semana 39
    • Semana 40
    • Semana 41
  • 2024
    • Semana 02
    • Semana 03
    • Semana 04
    • Semana 05
    • Semana 06
    • Semana 07
    • Semana 08
    • Semana 09
    • Semana 10
    • Semana 11
    • Semana 12
    • Semana 13
    • Semana 14
    • Semana 15
    • Semana 16
    • Semana 17
    • Semana 18
    • Semana 19
    • Semana 20
    • Semana 21
    • Semana 22
    • Semana 23
    • Semana 24
    • Semana 25
    • Semana 26
    • Semana 27
    • Semana 28
    • Semana 29
    • Semana 30
    • Semana 31
    • Semana 32
    • Semana 33
    • Semana 34
    • Semana 35
    • Semana 36
    • Semana 37
    • Semana 38
    • Semana 39
    • Semana 40
    • Semana 41
    • Semana 42
    • Semana 43
    • Semana 44
    • Semana 45
    • Semana 46
    • Semana 47
    • Semana 48
    • Semana 49
    • Semana 50
    • Semana 51
    • Semana 52
    • Semana 53
  • 2023
    • Semana 07
    • Semana 12
    • Semana 13
    • Semana 14
    • Semana 15
    • Semana 16
    • Semana 17
    • Semana 18
    • Semana 19
    • Semana 20
    • Semana 21
    • Semana 22
    • Semana 23
    • Semana 24
    • Semana 25
    • Semana 26
    • Semana 27
    • Semana 28
    • Semana 29
    • Semana 30
    • Semana 31
    • Semana 32
    • Semana 33
    • Semana 34
    • Semana 35
    • Semana 36
    • Semana 37
    • Semana 38
    • Semana 39
    • Semana 40
    • Semana 41
    • Semana 42
    • Semana 43
    • Semana 44
    • Semana 45
    • Semana 46
    • Semana 47
    • Semana 48
    • Semana 49
    • Semana 50
    • Semana 51
    • Semana 52

Contenido

  • Paquetes
  • Estilos
  • Epígrafe
  • Datos
  • Procesamiento
  • Figura
  • Editar esta página
  • Informar sobre problema
  1. 2025
  2. Semana 41

Semana 41

  • Mostrar todo el código
  • Ocultar todo el código

  • Ver el código fuente
GEOM_AAA
GEOM_BBB
GEOM_CCC
Autor

Víctor Gauto

Fecha de publicación

26 de octubre de 2025

Evolución de la cantidad de personas obesas en Argentina.

Semana 41, 2025

Paquetes

Ocultar código
library(glue)
library(ggtext)
library(showtext)
library(tidyverse)

Estilos

Colores.

Ocultar código
c1 <- "#ABC9C8"
c2 <- "#17164F"
c3 <- "white"
c4 <- "black"

Fuentes: Ubuntu y JetBrains Mono.

Ocultar código
font_add(
  family = "ubuntu",
  regular = "././fuente/Ubuntu-Regular.ttf",
  bold = "././fuente/Ubuntu-Bold.ttf",
  italic = "././fuente/Ubuntu-Italic.ttf"
)

font_add(
  family = "jet",
  regular = "././fuente/JetBrainsMonoNLNerdFontMono-Regular.ttf"
)

showtext_auto()
showtext_opts(dpi = 300)

Epígrafe

Ocultar código
fuente <- glue(
  "Datos: <span style='color:{c1};'><span style='font-family:jet;'>",
  "{{<b>tidytuesdayR</b>}}</span> semana 41, ",
  "<b>Organización de las<br>Naciones Unidas para la Alimentación y ",
  "la Agricultura</b>.</span>"
)

autor <- glue("<span style='color:{c1};'>**Víctor Gauto**</span>")
icon_twitter <- glue("<span style='font-family:jet;'>&#xf099;</span>")
icon_instagram <- glue("<span style='font-family:jet;'>&#xf16d;</span>")
icon_github <- glue("<span style='font-family:jet;'>&#xf09b;</span>")
icon_mastodon <- glue("<span style='font-family:jet;'>&#xf0ad1;</span>")
icon_bsky <- glue("<span style='font-family:jet;'>&#xe28e;</span>")
usuario <- glue("<span style='color:{c1};'>**vhgauto**</span>")
sep <- glue("**|**")

mi_caption <- glue(
  "{fuente}<br>{autor} {sep} {icon_github} {icon_twitter} {icon_instagram} ",
  "{icon_mastodon} {icon_bsky} {usuario}"
)

Datos

Ocultar código
tuesdata <- tidytuesdayR::tt_load(2025, 41)
food <- tuesdata$food_security

Procesamiento

Me interesa la evolución anual en la cantidad de adultos obesos. Agrego formato a los números e indico las unidades.

Ocultar código
d <- filter(
  food,
  Area == "Argentina" &
    Item == "Number of obese adults (18 years and older) (million)"
) |>
  select(año = Year_Start, valor = Value) |>
  mutate(
    label = format(
      valor,
      nsmall = 1,
      decimal.mark = ",",
      big.mark = "",
      trim = TRUE
    )
  ) %>%
  mutate(
    label = if_else(
      row_number() == nrow(.),
      paste0(label, " millones\nde personas"),
      label
    )
  )

Figura

Indico el patrón de diseño con una rampa de colores lineal.

Ocultar código
p <- grid::linearGradient(
  colours = colorRampPalette(c(c2, c1))(100),
  x1 = 0,
  y1 = 0,
  x2 = 0,
  y2 = 1
)

Título y figura.

Ocultar código
mi_titulo <- glue(
  "Entre 2005 y 2022 se duplicó la<br>cantidad de",
  "personas (+18 años)<br><b style='color: {c1};'>obesas</b> en",
  " **Argentina**"
)

g <- ggplot(d, aes(año, valor)) +
  geom_ribbon(aes(ymin = 5, ymax = valor), fill = p) +
  geom_line(color = c1, linewidth = 1) +
  geom_segment(
    aes(x = año, yend = valor, y = 5),
    color = c2,
    linewidth = .5,
    linetype = 3
  ) +
  geom_point(
    shape = 21,
    fill = c2,
    color = c1,
    size = 3,
    stroke = 1.3
  ) +
  geom_label(
    aes(label = label, hjust = hjust, vjust = vjust, size = valor),
    color = c3,
    hjust = 1,
    vjust = 0,
    show.legend = FALSE,
    fill = NA,
    label.padding = unit(0.4, "lines"),
    family = "jet",
    border.color = NA
  ) +
  geom_text(
    aes(y = 5, label = año),
    color = c3,
    family = "jet",
    vjust = rep(c(-.2, 1.2), length.out = nrow(d)),
    size = 4
  ) +
  annotate(
    geom = "richtext",
    x = I(0),
    y = I(.95),
    label = mi_titulo,
    fill = NA,
    color = c3,
    hjust = 0,
    label.color = NA,
    family = "ubuntu",
    size = 10
  ) +
  annotate(
    geom = "richtext",
    x = I(0),
    y = I(.5),
    label = mi_caption,
    hjust = 0,
    vjust = 0,
    color = c3,
    lineheight = 1.4,
    size = 4,
    fill = NA,
    label.color = NA
  ) +
  scale_x_continuous(breaks = scales::breaks_width(2)) +
  scale_size_area(max_size = 5.5) +
  coord_cartesian(ylim = c(5, NA), expand = FALSE, clip = "off") +
  theme_void(base_size = 10) +
  theme(
    plot.background = element_rect(fill = c2),
    plot.margin = margin(t = 50, b = 30, r = 30, l = 30)
  )

Guardo.

Ocultar código
ggsave(
  plot = g,
  filename = "tidytuesday/2025/semana_41.png",
  width = 30,
  height = 30,
  units = "cm"
)
Subir
Semana 40
2024
Ejecutar el código
---
format:
  html:
    code-fold: show
    code-summary: "Ocultar código"
    code-line-numbers: false
    code-annotations: false
    code-link: true
    code-tools:
        source: true
        toggle: true
        caption: "Código"
    code-overflow: scroll
    page-layout: full
editor_options:
  chunk_output_type: console
categories:
  - GEOM_AAA
  - GEOM_BBB
  - GEOM_CCC
execute:
  eval: false
  echo: true
  warning: false
title: "Semana 41"
date: last-modified
author: Víctor Gauto
---

Evolución de la cantidad de personas obesas en Argentina.

::: {.column-page-right}

![Semana 41, 2025](semana_41.png)

:::

## Paquetes

```{r}
library(glue)
library(ggtext)
library(showtext)
library(tidyverse)
```

## Estilos

Colores.

```{r}
c1 <- "#ABC9C8"
c2 <- "#17164F"
c3 <- "white"
c4 <- "black"
```

Fuentes: Ubuntu y JetBrains Mono.

```{r}
font_add(
  family = "ubuntu",
  regular = "././fuente/Ubuntu-Regular.ttf",
  bold = "././fuente/Ubuntu-Bold.ttf",
  italic = "././fuente/Ubuntu-Italic.ttf"
)

font_add(
  family = "jet",
  regular = "././fuente/JetBrainsMonoNLNerdFontMono-Regular.ttf"
)

showtext_auto()
showtext_opts(dpi = 300)
```

## Epígrafe

```{r}
fuente <- glue(
  "Datos: <span style='color:{c1};'><span style='font-family:jet;'>",
  "{{<b>tidytuesdayR</b>}}</span> semana 41, ",
  "<b>Organización de las<br>Naciones Unidas para la Alimentación y ",
  "la Agricultura</b>.</span>"
)

autor <- glue("<span style='color:{c1};'>**Víctor Gauto**</span>")
icon_twitter <- glue("<span style='font-family:jet;'>&#xf099;</span>")
icon_instagram <- glue("<span style='font-family:jet;'>&#xf16d;</span>")
icon_github <- glue("<span style='font-family:jet;'>&#xf09b;</span>")
icon_mastodon <- glue("<span style='font-family:jet;'>&#xf0ad1;</span>")
icon_bsky <- glue("<span style='font-family:jet;'>&#xe28e;</span>")
usuario <- glue("<span style='color:{c1};'>**vhgauto**</span>")
sep <- glue("**|**")

mi_caption <- glue(
  "{fuente}<br>{autor} {sep} {icon_github} {icon_twitter} {icon_instagram} ",
  "{icon_mastodon} {icon_bsky} {usuario}"
)
```

## Datos

```{r}
tuesdata <- tidytuesdayR::tt_load(2025, 41)
food <- tuesdata$food_security
```

## Procesamiento

Me interesa la evolución anual en la cantidad de adultos obesos. Agrego formato a los números e indico las unidades.

```{r}
d <- filter(
  food,
  Area == "Argentina" &
    Item == "Number of obese adults (18 years and older) (million)"
) |>
  select(año = Year_Start, valor = Value) |>
  mutate(
    label = format(
      valor,
      nsmall = 1,
      decimal.mark = ",",
      big.mark = "",
      trim = TRUE
    )
  ) %>%
  mutate(
    label = if_else(
      row_number() == nrow(.),
      paste0(label, " millones\nde personas"),
      label
    )
  )
```

## Figura

Indico el patrón de diseño con una rampa de colores lineal.

```{r}
p <- grid::linearGradient(
  colours = colorRampPalette(c(c2, c1))(100),
  x1 = 0,
  y1 = 0,
  x2 = 0,
  y2 = 1
)
```

Título y figura.

```{r}
mi_titulo <- glue(
  "Entre 2005 y 2022 se duplicó la<br>cantidad de",
  "personas (+18 años)<br><b style='color: {c1};'>obesas</b> en",
  " **Argentina**"
)

g <- ggplot(d, aes(año, valor)) +
  geom_ribbon(aes(ymin = 5, ymax = valor), fill = p) +
  geom_line(color = c1, linewidth = 1) +
  geom_segment(
    aes(x = año, yend = valor, y = 5),
    color = c2,
    linewidth = .5,
    linetype = 3
  ) +
  geom_point(
    shape = 21,
    fill = c2,
    color = c1,
    size = 3,
    stroke = 1.3
  ) +
  geom_label(
    aes(label = label, hjust = hjust, vjust = vjust, size = valor),
    color = c3,
    hjust = 1,
    vjust = 0,
    show.legend = FALSE,
    fill = NA,
    label.padding = unit(0.4, "lines"),
    family = "jet",
    border.color = NA
  ) +
  geom_text(
    aes(y = 5, label = año),
    color = c3,
    family = "jet",
    vjust = rep(c(-.2, 1.2), length.out = nrow(d)),
    size = 4
  ) +
  annotate(
    geom = "richtext",
    x = I(0),
    y = I(.95),
    label = mi_titulo,
    fill = NA,
    color = c3,
    hjust = 0,
    label.color = NA,
    family = "ubuntu",
    size = 10
  ) +
  annotate(
    geom = "richtext",
    x = I(0),
    y = I(.5),
    label = mi_caption,
    hjust = 0,
    vjust = 0,
    color = c3,
    lineheight = 1.4,
    size = 4,
    fill = NA,
    label.color = NA
  ) +
  scale_x_continuous(breaks = scales::breaks_width(2)) +
  scale_size_area(max_size = 5.5) +
  coord_cartesian(ylim = c(5, NA), expand = FALSE, clip = "off") +
  theme_void(base_size = 10) +
  theme(
    plot.background = element_rect(fill = c2),
    plot.margin = margin(t = 50, b = 30, r = 30, l = 30)
  )
```

Guardo.

```{r}
ggsave(
  plot = g,
  filename = "tidytuesday/2025/semana_41.png",
  width = 30,
  height = 30,
  units = "cm"
)
```

Creado con y

Víctor Gauto

  • Editar esta página
  • Informar sobre problema