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

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
    • Semana 42
    • Semana 43
    • Semana 44
    • Semana 45
  • 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 45

Semana 45

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

  • Ver el código fuente
geom_richtext
Autor

Víctor Gauto

Fecha de publicación

19 de noviembre de 2025

Cantidad de casos de tuberculosis cada 100000 habitantes en Argentina.

Semana 45, 2025

Paquetes

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

Estilos

Colores.

Ocultar código
col <- nord::nord(palette = "polarnight", n = 4)
c1 <- "#D8DEE9"
c2 <- "#D8DEE9"

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 45, ",
  "<b>getTBinR</b>, Sam Abbott.</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, 45)
who_tb_data <- tuesdata$who_tb_data

Procesamiento

Me interesan los casos cada 100000 habitantes en Argentina.

Filtro los datos para Argentina y agrego la columna y con las unidades de cantidad de casos.

Ocultar código
d <- filter(who_tb_data, country == "Argentina") |>
  select(year, e_inc_100k) |>
  mutate(l = as.list(e_inc_100k)) |>
  mutate(y = map(l, ~ 1:.x)) |>
  unnest(y)

Defino símbolos para la calavera () y los pulmones ().

Ocultar código
calavera <- glue("<span style='font-family:jet;'>&#xf068c;</span>")
pulmón <- glue("<span style='font-family:jet;'>&#xe25b;</span>")

Figura

Título y figura.

Ocultar código
mi_titulo <- glue(
  "Casos de <b style='color: {c1};'>tuberculosis</b> en Argentina ",
  "cada **100.000** habitantes"
)

g <- ggplot(d, aes(year, y)) +
  annotate(
    geom = "richtext",
    x = I(.5),
    y = I(.5),
    fill = NA,
    label.color = NA,
    label = calavera,
    size = 360,
    color = col[2]
  ) +
  geom_richtext(
    label = pulmón,
    color = c2,
    family = "jet",
    fill = NA,
    label.color = NA,
    size = 9
  ) +
  scale_x_continuous(expand = expansion(mult = 0, add = .5)) +
  scale_y_continuous(
    breaks = c(1, seq(5, 35, 5)),
    expand = expansion(mult = 0, add = .7)
  ) +
  labs(title = mi_titulo, caption = mi_caption) +
  coord_equal() +
  theme_void(base_size = 14, base_family = "ubuntu") +
  theme_sub_legend(position = "none") +
  theme_sub_plot(
    background = element_rect(fill = col[1]),
    title = element_markdown(hjust = .5, size = rel(2), color = c2),
    title.position = "plot",
    margin = margin(b = 15, t = 10),
    caption = element_markdown(
      size = rel(1.2),
      color = c2,
      lineheight = 1.2,
      margin = margin(t = 15, b = 15)
    )
  ) +
  theme_sub_axis(
    text = element_text(color = c1, family = "jet", size = rel(1.3)),
    ticks = element_line(color = c1),
    ticks.length = unit(5, "pt")
  ) +
  theme_sub_axis_y(text = element_text(margin = margin(r = 5))) +
  theme_sub_axis_x(text = element_text(margin = margin(t = 5)))

Guardo.

Ocultar código
ggsave(
  plot = g,
  filename = "tidytuesday/2025/semana_45.png",
  width = 30,
  height = 45,
  units = "cm"
)
Subir
Semana 44
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_richtext
execute:
  eval: false
  echo: true
  warning: false
title: "Semana 45"
date: last-modified
author: Víctor Gauto
---

Cantidad de casos de tuberculosis cada 100000 habitantes en Argentina.

::: {.column-page-right}

![Semana 45, 2025](semana_45.png)

:::

## Paquetes

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

## Estilos

Colores.

```{r}
col <- nord::nord(palette = "polarnight", n = 4)
c1 <- "#D8DEE9"
c2 <- "#D8DEE9"
```

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 45, ",
  "<b>getTBinR</b>, Sam Abbott.</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, 45)
who_tb_data <- tuesdata$who_tb_data
```

## Procesamiento

Me interesan los casos cada 100000 habitantes en Argentina.

Filtro los datos para Argentina y agrego la columna `y` con las unidades de cantidad de casos.

```{r}
d <- filter(who_tb_data, country == "Argentina") |>
  select(year, e_inc_100k) |>
  mutate(l = as.list(e_inc_100k)) |>
  mutate(y = map(l, ~ 1:.x)) |>
  unnest(y)
```

Defino símbolos para la calavera (<i class="nf nf-fa-skull"></i>) y los pulmones (<i class="nf nf-fae-lung"></i>).

```{r}
calavera <- glue("<span style='font-family:jet;'>&#xf068c;</span>")
pulmón <- glue("<span style='font-family:jet;'>&#xe25b;</span>")
```

## Figura

Título y figura.

```{r}
mi_titulo <- glue(
  "Casos de <b style='color: {c1};'>tuberculosis</b> en Argentina ",
  "cada **100.000** habitantes"
)

g <- ggplot(d, aes(year, y)) +
  annotate(
    geom = "richtext",
    x = I(.5),
    y = I(.5),
    fill = NA,
    label.color = NA,
    label = calavera,
    size = 360,
    color = col[2]
  ) +
  geom_richtext(
    label = pulmón,
    color = c2,
    family = "jet",
    fill = NA,
    label.color = NA,
    size = 9
  ) +
  scale_x_continuous(expand = expansion(mult = 0, add = .5)) +
  scale_y_continuous(
    breaks = c(1, seq(5, 35, 5)),
    expand = expansion(mult = 0, add = .7)
  ) +
  labs(title = mi_titulo, caption = mi_caption) +
  coord_equal() +
  theme_void(base_size = 14, base_family = "ubuntu") +
  theme_sub_legend(position = "none") +
  theme_sub_plot(
    background = element_rect(fill = col[1]),
    title = element_markdown(hjust = .5, size = rel(2), color = c2),
    title.position = "plot",
    margin = margin(b = 15, t = 10),
    caption = element_markdown(
      size = rel(1.2),
      color = c2,
      lineheight = 1.2,
      margin = margin(t = 15, b = 15)
    )
  ) +
  theme_sub_axis(
    text = element_text(color = c1, family = "jet", size = rel(1.3)),
    ticks = element_line(color = c1),
    ticks.length = unit(5, "pt")
  ) +
  theme_sub_axis_y(text = element_text(margin = margin(r = 5))) +
  theme_sub_axis_x(text = element_text(margin = margin(t = 5)))
```

Guardo.

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

Creado con y

Víctor Gauto

  • Editar esta página
  • Informar sobre problema