```{r}
#| label: plot
### |- final plot ----
p <- ggplot(chess_data, aes(x = rating)) +
# Geoms
# Reference text layer
as_reference(
geom_text(
data = labels, aes(x = x, y = y, label = label),
family = "title", colour = "gray10", size = rel(35), hjust = 0.5, vjust = 0
),
id = "text"
) +
# Blending the text with the density plot
with_inner_glow(
with_blend(
geom_density(aes(fill = player, color = player),
alpha = 1, show.legend = FALSE,
bw = 25,
kernel = "epanechnikov"
),
bg_layer = "text", blend_type = "xor"
),
color = "gray10", sigma = 15
) +
# Labs
labs(
x = "Player Rating",
y = NULL,
title = title_text,
subtitle = subtitle_text,
caption = caption_text
) +
# Scales
scale_x_continuous() +
scale_y_continuous() +
scale_fill_manual(values = col_palette) +
scale_color_manual(values = col_palette) +
coord_cartesian(clip = "off") +
# Facet
facet_wrap(~player, ncol = 1) +
# Theme
theme(
plot.title = element_text(
size = rel(1.55),
family = "title",
face = "bold",
color = title_col,
lineheight = 1.1,
margin = margin(t = 5, b = 5)
),
plot.subtitle = element_text(
size = rel(0.85),
family = "subtitle",
color = subtitle_col,
lineheight = 1.1,
margin = margin(t = 5, b = 5)
),
plot.caption = element_markdown(
size = rel(0.50),
family = "caption",
color = caption_col,
lineheight = 1.1,
hjust = 0.5,
halign = 1,
margin = margin(t = 5, b = 5)
)
)
```