---
title: "Italy industrialized unevenly"
subtitle: "Indexed production reveals diverging paths across Italian industries, 1861–1985"
description: "A two-panel chart examining over a century of Italian industrial production using ISTAT historical data. Panel A indexes Raw Silk and Total Textiles to their first available year (= 100), revealing diverging trajectories: silk peaked around 1910 and entered long structural decline, while textiles recovered strongly after WWII and stabilized as a postwar manufacturing anchor. Panel B tracks average gross tonnage per ship launched — a derived metric showing Italy's shipbuilding shift from many small vessels to fewer, heavier ones, peaking at 14,692 tons/ship in
the early 1970s. Built with ggplot2 and patchwork in R."
date: "2026-05-03"
author:
- name: "Steven Ponce"
url: "https://stevenponce.netlify.app"
citation:
url: "https://stevenponce.netlify.app/data_visualizations/TidyTuesday/2026/tt_2026_18.html"
categories: ["TidyTuesday", "2026"]
tags: [
"Agricultural Tariffs",
]
image: "thumbnails/tt_2026_18.png"
format:
html:
toc: true
toc-depth: 5
code-link: true
code-fold: true
code-tools: true
code-summary: "Show code"
theme:
light: [flatly, assets/styling/custom_styles.scss]
dark: [darkly, assets/styling/custom_styles_dark.scss]
editor_options:
chunk_output_type: inline
execute:
freeze: true
cache: true
error: false
message: false
warning: false
eval: true
---
{#fig-1}
### [**Steps to Create this Graphic**]{.mark}
#### [1. Load Packages & Setup]{.smallcaps}
```{r}
#| label: load
#| warning: false
#| message: false
#| results: "hide"
## 1. LOAD PACKAGES & SETUP ----
suppressPackageStartupMessages({
if (!require("pacman")) install.packages("pacman")
pacman::p_load(
tidyverse, ggtext, showtext, janitor, ggrepel,
scales, glue, skimr, patchwork
)
})
### |- figure size ----
camcorder::gg_record(
dir = here::here("temp_plots"),
device = "png",
width = 11,
height = 10,
units = "in",
dpi = 320
)
# Source utility functions
suppressMessages(source(here::here("R/utils/fonts.R")))
source(here::here("R/utils/social_icons.R"))
source(here::here("R/utils/image_utils.R"))
source(here::here("R/themes/base_theme.R"))
```
#### [2. Read in the Data]{.smallcaps}
```{r}
#| label: read
#| include: true
#| eval: true
#| warning: false
tt <- tidytuesdayR::tt_load(2026, week = 18)
food_beverages <- tt$food_beverages |> clean_names()
textiles <- tt$textiles |> clean_names()
transport <- tt$transport |> clean_names()
rm(tt)
```
#### [3. Examine the Data]{.smallcaps}
```{r}
#| label: examine
#| include: true
#| eval: true
#| results: 'hide'
#| warning: false
glimpse(food_beverages)
glimpse(textiles)
glimpse(transport)
```
#### [4. Tidy Data]{.smallcaps}
```{r}
#| label: tidy
#| warning: false
### |- Panel A: Indexed growth series ----
# Select 5 representative series across the three datasets.
# Index each to its own first non-NA year (= 100) so cross-industry
# comparisons reflect relative change, not raw volume or units.
panel_a_raw <- bind_rows(
food_beverages |>
select(year, beer, sugar, ethyl_alcohol_1) |>
pivot_longer(-year, names_to = "series", values_to = "value"),
textiles |>
select(year, total_textiles, raw_silk) |>
pivot_longer(-year, names_to = "series", values_to = "value")
)
panel_a_indexed <- panel_a_raw |>
filter(!is.na(value)) |>
filter(series %in% c("total_textiles", "raw_silk")) |>
group_by(series) |>
mutate(
base_value = first(value),
base_year = first(year),
indexed = value / base_value * 100
) |>
ungroup() |>
mutate(
series_label = case_when(
series == "total_textiles" ~ "Total Textiles",
series == "raw_silk" ~ "Raw Silk"
),
color_role = case_when(
series == "raw_silk" ~ "decline",
series == "total_textiles" ~ "core"
)
)
### |- Panel B: Average ship weight (derived metric) ----
# avg_ship_weight = ships_weight / ships_launched
# A proxy for industrial capability: fewer but heavier ships = upgrading
panel_b <- transport |>
filter(!is.na(ships_weight), !is.na(ships_launched), ships_launched > 0) |>
mutate(avg_ship_weight = ships_weight / ships_launched) |>
select(year, avg_ship_weight, ships_launched, ships_weight)
# Identify annotatable inflection points for Panel B narrative
panel_b_annotations <- panel_b |>
summarise(
early_median = median(avg_ship_weight[year <= 1900], na.rm = TRUE),
late_median = median(avg_ship_weight[year >= 1960], na.rm = TRUE),
peak_year = year[which.max(avg_ship_weight)],
peak_val = max(avg_ship_weight, na.rm = TRUE)
)
```
#### [5. Visualization Parameters]{.smallcaps}
```{r}
#| label: params
#| include: true
#| warning: false
### |- plot aesthetics ----
colors <- get_theme_colors(
palette = list(
"rise" = "#722F37",
"decline" = "#4A6FA5",
"core" = "#C26A3D",
"neutral" = "gray75"
)
)
### |- titles and captions ----
title_text <- str_glue("Italy industrialized unevenly")
subtitle_a <- str_glue(
"Indexed to first available year (= 100).",
" Silk declined; textiles rose and stabilized.<br>",
"<span style='color:{colors$palette$decline}'>Raw Silk</span>: Italy's oldest fiber industry, in long retreat;",
" <span style='color:{colors$palette$core}'>Total Textiles</span>: postwar manufacturing anchor."
)
title_b <- str_glue("Ships became fewer but heavier")
subtitle_b <- str_glue(
"Average gross tonnage per ship launched — a proxy for industrial capability."
)
caption_text <- create_social_caption(
tt_year = 2026,
tt_week = 18,
source_text = "ISTAT — Sommari di statistiche storiche (1861–1985)"
)
caption_b_note <- str_glue(
"Note: Before 1951, values refer to fiscal years; from 1951 onward, calendar years."
)
### |- fonts ----
setup_fonts()
fonts <- get_font_families()
### |- base theme ----
base_theme <- create_base_theme(colors)
weekly_theme <- extend_weekly_theme(
base_theme,
theme(
plot.title = element_text(
face = "bold", family = fonts$title,
size = rel(1.3), hjust = 0, margin = margin(b = 4)
),
plot.subtitle = element_markdown(
family = fonts$text,
size = rel(0.85), hjust = 0,
lineheight = 1.3, margin = margin(b = 10)
),
plot.caption = element_markdown(
family = fonts$text,
size = rel(0.7), hjust = 0,
color = "gray50", margin = margin(t = 10)
),
axis.title = element_text(
family = fonts$text, size = rel(0.8), color = "gray40"
),
axis.text = element_text(
family = fonts$text, size = rel(0.75), color = "gray50"
),
panel.grid.major.y = element_line(color = "gray92", linewidth = 0.3),
panel.grid.major.x = element_blank(),
panel.grid.minor = element_blank(),
axis.ticks = element_blank(),
strip.text = element_blank()
)
)
theme_set(weekly_theme)
```
#### [6. Plot]{.smallcaps}
```{r}
#| label: plot
#| warning: false
### |- Panel A: Indexed divergence ----
role_colors <- c(
"decline" = colors$palette$decline,
"core" = colors$palette$core
)
role_linewidth <- c(
"decline" = 1.4,
"core" = 1.4
)
role_alpha <- c(
"decline" = 1,
"core" = 1
)
p_a <- panel_a_indexed |>
ggplot(aes(
x = year, y = indexed,
group = series_label,
color = color_role,
linewidth = color_role,
alpha = color_role
)) +
annotate("rect",
xmin = 1915, xmax = 1918,
ymin = -Inf, ymax = Inf,
fill = "gray80", alpha = 0.10
) +
annotate("rect",
xmin = 1940, xmax = 1945,
ymin = -Inf, ymax = Inf,
fill = "gray80", alpha = 0.10
) +
geom_vline(
xintercept = 1951,
linetype = "dotted",
linewidth = 0.3,
color = "gray65"
) +
annotate(
"text",
x = 1952, y = Inf,
label = "Calendar-year reporting begins",
hjust = 0, vjust = 1.5,
size = 2.5,
family = fonts$text,
color = "gray45"
) +
# Geoms
geom_hline(
yintercept = 100, linetype = "dashed",
linewidth = 0.3, color = "gray60"
) +
geom_line(lineend = "round") +
geom_text(
data = panel_a_indexed |>
group_by(series_label, color_role) |>
slice_max(year, n = 1) |>
ungroup() |>
mutate(
y_nudge = case_when(
series_label == "Raw Silk" ~ -12,
series_label == "Total Textiles" ~ 8,
TRUE ~ 0
),
y_final = indexed + y_nudge
),
aes(x = year, y = y_final, label = series_label, color = color_role),
hjust = -0.12, size = 2.8,
family = fonts$text,
fontface = "bold",
show.legend = FALSE
) +
# Scales
scale_color_manual(values = role_colors, guide = "none") +
scale_linewidth_manual(values = role_linewidth, guide = "none") +
scale_alpha_manual(values = role_alpha, guide = "none") +
scale_x_continuous(
breaks = seq(1870, 1980, by = 20),
expand = expansion(mult = c(0.02, 0.18))
) +
scale_y_continuous(
labels = label_number(suffix = "×", scale = 0.01, accuracy = 0.1),
breaks = c(0, 0.5, 1, 1.5, 2, 2.5, 3) * 100,
limits = c(0, NA)
) +
coord_cartesian(clip = "off") +
# annotate
annotate("text",
x = 1916.5, y = Inf,
label = "WWI", hjust = 0.5, vjust = 2,
size = 2.3, color = "gray50", family = fonts$text
) +
annotate("text",
x = 1942.5, y = Inf,
label = "WWII", hjust = 0.5, vjust = 2,
size = 2.3, color = "gray50", family = fonts$text
) +
annotate("text",
x = 1944, y = 0.35,
label = "WWII collapse",
hjust = 0.5, vjust = 1,
size = 2.4, color = "gray45",
family = fonts$text
) +
# Labs
labs(
subtitle = subtitle_a,
x = NULL,
y = "Production index"
)
### |- Panel B: Ship sophistication ----
# Find key annotation years
peak_row <- panel_b |> slice_max(avg_ship_weight, n = 1)
early_row <- panel_b |>
filter(year <= 1890) |>
slice_min(year, n = 1)
p_b <- panel_b |>
ggplot(aes(x = year, y = avg_ship_weight)) +
# Geoms
geom_line(
color = colors$palette$core,
linewidth = 0.85,
lineend = "round"
) +
# Annotate
annotate("text",
x = 1878, y = 1800,
label = "Many small ships\n(capacity era)",
hjust = 0.5, vjust = 0,
size = 2.6, color = "gray45",
family = fonts$text, lineheight = 1.2
) +
annotate("point",
x = peak_row$year, y = peak_row$avg_ship_weight,
color = colors$palette$rise, size = 2.2
) +
annotate("text",
x = peak_row$year + 2, y = peak_row$avg_ship_weight + 2200,
label = glue("{scales::comma(round(peak_row$avg_ship_weight))} tons/ship"),
hjust = 0, vjust = 0,
size = 2.4, color = "gray35",
family = fonts$text, lineheight = 1.2
) +
annotate("text",
x = 1965, y = peak_row$avg_ship_weight * 0.55,
label = "Fewer, heavier ships\n(capability era)",
hjust = 0.5, vjust = 1,
size = 2.6, color = "gray45",
family = fonts$text, lineheight = 1.2
) +
# Scales
scale_x_continuous(breaks = seq(1860, 1980, by = 20)) +
scale_y_continuous(labels = label_comma()) +
# Scales
labs(
title = title_b,
subtitle = subtitle_b,
x = NULL,
y = "Avg. gross tonnage per ship (tons)",
caption = glue("{caption_b_note}<br>{caption_text}")
) +
# Theme
theme(
plot.title = element_text(
face = "bold",
family = fonts$title,
size = rel(1.05),
hjust = 0,
margin = margin(b = 3)
),
plot.subtitle = element_markdown(
family = 'sans',
size = rel(0.8),
hjust = 0,
color = "gray40",
margin = margin(b = 8)
)
)
### |- Combine plots ----
p_final <- (p_a / p_b) +
plot_layout(heights = c(1.55, 1)) +
plot_annotation(
title = title_text,
theme = theme(
plot.title = element_text(
face = "bold",
family = fonts$title,
size = rel(1.6),
hjust = 0,
margin = margin(b = 6)
),
plot.margin = margin(t = 16, r = 20, b = 12, l = 16)
)
)
```
#### [7. Save]{.smallcaps}
```{r}
#| label: save
#| warning: false
### |- plot image ----
save_plot_patchwork(
plot = p_final,
type = "tidytuesday",
year = 2026,
week = 18,
width = 11,
height = 10
)
```
#### [8. Session Info]{.smallcaps}
::: {.callout-tip collapse="true"}
##### Expand for Session Info
```{r, echo = FALSE}
#| eval: true
#| warning: false
sessionInfo()
```
:::
#### [9. GitHub Repository]{.smallcaps}
::: {.callout-tip collapse="true"}
##### Expand for GitHub Repo
The complete code for this analysis is available in [`tt_2026_18.qmd`](https://github.com/poncest/personal-website/blob/master/data_visualizations/TidyTuesday/2026/tt_2026_18.qmd).
For the full repository, [click here](https://github.com/poncest/personal-website/).
:::
#### [10. References]{.smallcaps}
::: {.callout-tip collapse="true"}
##### Expand for References
1. **Data Source:**
- TidyTuesday 2026 Week 18: [Italian Industrial Production](https://github.com/rfordatascience/tidytuesday/blob/main/data/2026/2026-05-05readme.md)
:::
#### [11. Custom Functions Documentation]{.smallcaps}
::: {.callout-note collapse="true"}
##### 📦 Custom Helper Functions
This analysis uses custom functions from my personal module library for efficiency and consistency across projects.
**Functions Used:**
- **`fonts.R`**: `setup_fonts()`, `get_font_families()` - Font management with showtext
- **`social_icons.R`**: `create_social_caption()` - Generates formatted social media captions
- **`image_utils.R`**: `save_plot()` - Consistent plot saving with naming conventions
- **`base_theme.R`**: `create_base_theme()`, `extend_weekly_theme()`, `get_theme_colors()` - Custom ggplot2 themes
**Why custom functions?**\
These utilities standardize theming, fonts, and output across all my data visualizations. The core analysis (data tidying and visualization logic) uses only standard tidyverse packages.
**Source Code:**\
View all custom functions → [GitHub: R/utils](https://github.com/poncest/personal-website/tree/master/R)
:::