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

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
  • 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 de un problema
  1. 2025
  2. Semana 36

Semana 36

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

  • Ver el código fuente
geom_label
geom_bump
Autor

Víctor Gauto

Fecha de publicación

11 de septiembre de 2025

Cantidad de países que pueden visitarse sin una visa previa, para portadores de pasaportes de una selección de países sudamericanos.

Semana 36, 2025

Paquetes

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

Estilos

Colores.

Ocultar código
c1 <- "#48171C"
c2 <- "#004042"
c3 <- "white"
c4 <- "black"
c5 <- "grey60"
c6 <- "grey90"
c7 <- "grey95"

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 36, ",
  "<b>Henley Passport Index</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, 36)
rank_by_year <- tuesdata$rank_by_year

Procesamiento

Me interesa la cantidad de países que se pueden visitar con cada pasaporte.

Selección de países sudamericanos y paleta de colores.

Ocultar código
paises <- c(
  "Argentina",
  "Chile",
  "Brazil",
  "Uruguay",
  "Bolivia",
  "Venezuela",
  "Colombia",
  "Paraguay",
  "Ecuador"
)

colores <- c(
  MoMAColors::moma.colors(palette_name = "Abbott"),
  c1
)

Filtro los datos, aplico colores y genero factores, considerando la traducción de Brasil.

Ocultar código
d <- rank_by_year |>
  filter(country %in% paises) |>
  filter(visa_free_count != 0) |>
  mutate(id = map_dbl(.x = country, ~ which(.x == paises))) |>
  mutate(color = colores[id]) |>
  mutate(
    label = glue("<b style='color: {color}'>{country}</b>")
  ) |>
  arrange(country, year) |>
  mutate(label = str_replace(label, "Brazil", "Brasil")) |>
  mutate(label = fct_inorder(label))

Obtengo los valores para los años extremos y aplico espaciado a las etiquetas.

Ocultar código
espacio <- 5

d_min <- slice_min(d, order_by = year, n = 1)

d_max <- slice_max(d, order_by = year, n = 1)

d_min_max <- rbind(d_min, d_max) |>
  mutate(
    visa_free_count = if_else(
      year == 2006,
      visa_free_count + espacio,
      visa_free_count - espacio
    )
  ) |>
  mutate(hjust = if_else(year == 2006, 1, 0))

Figura

Título y figura.

Ocultar código
mi_titulo <- glue(
  "Evolución de la cantidad de países que se pueden visitar **SIN** una",
  "<span style='color: {colores[1]}'>*visa*</span> previa para una selección",
  "de <b style='color: {colores[8]}'>países sudamericanos</b>",
  .sep = " "
)

g <- ggplot(d, aes(year, visa_free_count, color = country)) +
  geom_label(
    data = d_min_max,
    aes(year, visa_free_count, label = visa_free_count, hjust = hjust),
    family = "jet",
    fill = c6,
    label.size = unit(0, "pt"),
    label.r = unit(0, "pt"),
    label.padding = unit(2, "pt"),
    fontface = "bold"
  ) +
  ggbump::geom_bump(linewidth = 3, lineend = "round") +
  ggbump::geom_bump(
    data = select(d, -label),
    aes(year, visa_free_count, group = country),
    inherit.aes = FALSE,
    linewidth = 1,
    alpha = .2,
    lineend = "round",
    color = c5
  ) +
  ggbump::geom_bump(
    aes(group = country),
    linewidth = .7,
    lineend = "round",
    color = c7
  ) +
  facet_wrap(vars(label), ncol = 3, scales = "fixed", axes = "margins") +
  scale_color_manual(
    breaks = paises,
    values = colores
  ) +
  scale_y_continuous(breaks = scales::breaks_width(50)) +
  coord_cartesian(clip = "off") +
  labs(y = NULL, x = NULL, title = mi_titulo, caption = mi_caption) +
  theme_void(base_size = 12, base_family = "ubuntu") +
  theme(
    aspect.ratio = 1,
    plot.background = element_rect(fill = c7, color = NA),
    plot.margin = margin(t = 10, b = 7, r = 13, l = 10),
    plot.title = element_textbox_simple(
      size = rel(1.7),
      margin = margin(b = 8)
    ),
    plot.caption = element_markdown(
      color = c2,
      size = rel(1.1),
      lineheight = 1.1,
      margin = margin(t = 13)
    ),
    legend.position = "none",
    axis.text.x = element_text(
      family = "jet",
      size = rel(1.1),
      color = c4,
      margin = margin(t = 3)
    ),
    axis.text.y = element_text(
      family = "jet",
      color = c5,
      size = rel(.9),
      hjust = 1,
      angle = 90
    ),
    panel.background = element_rect(fill = c6, color = NA),
    panel.grid.major = element_line(
      color = c5,
      linewidth = .1,
      linetype = "FF"
    ),
    panel.spacing.x = unit(25, "pt"),
    panel.spacing.y = unit(10, "pt"),
    strip.text = element_markdown(
      hjust = 0,
      fill = c7,
      padding = unit(c(3, 3, 3, 3), "pt"),
      size = rel(1.7),
      margin = margin(b = -30)
    ),
    strip.background = element_blank()
  )

Guardo.

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

Cantidad de países que pueden visitarse sin una visa previa, para portadores de pasaportes de una selección de países sudamericanos.

::: {.column-page-right}

![Semana 36, 2025](semana_36.png)

:::

## Paquetes

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

## Estilos

Colores.

```{r}
c1 <- "#48171C"
c2 <- "#004042"
c3 <- "white"
c4 <- "black"
c5 <- "grey60"
c6 <- "grey90"
c7 <- "grey95"
```

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 36, ",
  "<b>Henley Passport Index</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, 36)
rank_by_year <- tuesdata$rank_by_year
```

## Procesamiento

Me interesa la cantidad de países que se pueden visitar con cada pasaporte.

Selección de países sudamericanos y paleta de colores.

```{r}
paises <- c(
  "Argentina",
  "Chile",
  "Brazil",
  "Uruguay",
  "Bolivia",
  "Venezuela",
  "Colombia",
  "Paraguay",
  "Ecuador"
)

colores <- c(
  MoMAColors::moma.colors(palette_name = "Abbott"),
  c1
)
```

Filtro los datos, aplico colores y genero factores, considerando la traducción de Brasil.

```{r}
d <- rank_by_year |>
  filter(country %in% paises) |>
  filter(visa_free_count != 0) |>
  mutate(id = map_dbl(.x = country, ~ which(.x == paises))) |>
  mutate(color = colores[id]) |>
  mutate(
    label = glue("<b style='color: {color}'>{country}</b>")
  ) |>
  arrange(country, year) |>
  mutate(label = str_replace(label, "Brazil", "Brasil")) |>
  mutate(label = fct_inorder(label))
```

Obtengo los valores para los años extremos y aplico espaciado a las etiquetas.

```{r}
espacio <- 5

d_min <- slice_min(d, order_by = year, n = 1)

d_max <- slice_max(d, order_by = year, n = 1)

d_min_max <- rbind(d_min, d_max) |>
  mutate(
    visa_free_count = if_else(
      year == 2006,
      visa_free_count + espacio,
      visa_free_count - espacio
    )
  ) |>
  mutate(hjust = if_else(year == 2006, 1, 0))
```

## Figura

Título y figura.

```{r}
mi_titulo <- glue(
  "Evolución de la cantidad de países que se pueden visitar **SIN** una",
  "<span style='color: {colores[1]}'>*visa*</span> previa para una selección",
  "de <b style='color: {colores[8]}'>países sudamericanos</b>",
  .sep = " "
)

g <- ggplot(d, aes(year, visa_free_count, color = country)) +
  geom_label(
    data = d_min_max,
    aes(year, visa_free_count, label = visa_free_count, hjust = hjust),
    family = "jet",
    fill = c6,
    label.size = unit(0, "pt"),
    label.r = unit(0, "pt"),
    label.padding = unit(2, "pt"),
    fontface = "bold"
  ) +
  ggbump::geom_bump(linewidth = 3, lineend = "round") +
  ggbump::geom_bump(
    data = select(d, -label),
    aes(year, visa_free_count, group = country),
    inherit.aes = FALSE,
    linewidth = 1,
    alpha = .2,
    lineend = "round",
    color = c5
  ) +
  ggbump::geom_bump(
    aes(group = country),
    linewidth = .7,
    lineend = "round",
    color = c7
  ) +
  facet_wrap(vars(label), ncol = 3, scales = "fixed", axes = "margins") +
  scale_color_manual(
    breaks = paises,
    values = colores
  ) +
  scale_y_continuous(breaks = scales::breaks_width(50)) +
  coord_cartesian(clip = "off") +
  labs(y = NULL, x = NULL, title = mi_titulo, caption = mi_caption) +
  theme_void(base_size = 12, base_family = "ubuntu") +
  theme(
    aspect.ratio = 1,
    plot.background = element_rect(fill = c7, color = NA),
    plot.margin = margin(t = 10, b = 7, r = 13, l = 10),
    plot.title = element_textbox_simple(
      size = rel(1.7),
      margin = margin(b = 8)
    ),
    plot.caption = element_markdown(
      color = c2,
      size = rel(1.1),
      lineheight = 1.1,
      margin = margin(t = 13)
    ),
    legend.position = "none",
    axis.text.x = element_text(
      family = "jet",
      size = rel(1.1),
      color = c4,
      margin = margin(t = 3)
    ),
    axis.text.y = element_text(
      family = "jet",
      color = c5,
      size = rel(.9),
      hjust = 1,
      angle = 90
    ),
    panel.background = element_rect(fill = c6, color = NA),
    panel.grid.major = element_line(
      color = c5,
      linewidth = .1,
      linetype = "FF"
    ),
    panel.spacing.x = unit(25, "pt"),
    panel.spacing.y = unit(10, "pt"),
    strip.text = element_markdown(
      hjust = 0,
      fill = c7,
      padding = unit(c(3, 3, 3, 3), "pt"),
      size = rel(1.7),
      margin = margin(b = -30)
    ),
    strip.background = element_blank()
  )


```

Guardo.

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

Creado con y

Víctor Gauto

  • Editar esta página
  • Informar de un problema