last updates
This commit is contained in:
parent
e0ad813644
commit
6179322988
6 changed files with 36 additions and 3 deletions
|
|
@ -1 +1 @@
|
||||||
,pab,onigashima,26.05.2026 10:40,file:///home/pab/.config/libreoffice/4;
|
,pab,onigashima,26.05.2026 11:03,file:///home/pab/.config/libreoffice/4;
|
||||||
Binary file not shown.
|
|
@ -72,7 +72,7 @@ row_df <- as.data.frame(afc$row$coord[, 1:2]) |>
|
||||||
label_munis <- c("Stockholm", "Göteborg", "Malmö", "Uppsala", "Lund", "Umeå",
|
label_munis <- c("Stockholm", "Göteborg", "Malmö", "Uppsala", "Lund", "Umeå",
|
||||||
"Linköping", "Solna", "Danderyd", "Kiruna", "Gotland",
|
"Linköping", "Solna", "Danderyd", "Kiruna", "Gotland",
|
||||||
"Knivsta", "Falköping", "Tomelilla", "Skellefteå", "Piteå",
|
"Knivsta", "Falköping", "Tomelilla", "Skellefteå", "Piteå",
|
||||||
"Partille", "Sundbyberg", "Lindesberg")
|
"Partille", "Sundbyberg", "Lindesberg", "Gävle")
|
||||||
|
|
||||||
contribs <- as.data.frame(afc$col$contrib) |>
|
contribs <- as.data.frame(afc$col$contrib) |>
|
||||||
rownames_to_column("variable") |>
|
rownames_to_column("variable") |>
|
||||||
|
|
@ -84,15 +84,22 @@ col_df <- as.data.frame(afc$col$coord[, 1:2]) |>
|
||||||
rownames_to_column("variable") |>
|
rownames_to_column("variable") |>
|
||||||
filter(variable %in% contribs$variable)
|
filter(variable %in% contribs$variable)
|
||||||
|
|
||||||
|
highlight_munis <- c("Gävle")
|
||||||
|
|
||||||
fig_biplot <- ggplot() +
|
fig_biplot <- ggplot() +
|
||||||
geom_hline(yintercept = 0, linetype = "dashed", colour = "grey60") +
|
geom_hline(yintercept = 0, linetype = "dashed", colour = "grey60") +
|
||||||
geom_vline(xintercept = 0, linetype = "dashed", colour = "grey60") +
|
geom_vline(xintercept = 0, linetype = "dashed", colour = "grey60") +
|
||||||
geom_point(data = row_df,
|
geom_point(data = row_df,
|
||||||
aes(`Dim 1`, `Dim 2`, colour = cluster_label),
|
aes(`Dim 1`, `Dim 2`, colour = cluster_label),
|
||||||
alpha = 0.75, size = 2.2) +
|
alpha = 0.75, size = 2.2) +
|
||||||
|
geom_point(data = row_df |> filter(municipality %in% highlight_munis),
|
||||||
|
aes(`Dim 1`, `Dim 2`),
|
||||||
|
shape = 21, size = 5, stroke = 1.5,
|
||||||
|
fill = NA, colour = "black") +
|
||||||
geom_text_repel(
|
geom_text_repel(
|
||||||
data = row_df |> filter(municipality %in% label_munis),
|
data = row_df |> filter(municipality %in% label_munis),
|
||||||
aes(`Dim 1`, `Dim 2`, label = municipality),
|
aes(`Dim 1`, `Dim 2`, label = municipality,
|
||||||
|
fontface = if_else(municipality %in% highlight_munis, "bold", "plain")),
|
||||||
size = 5, colour = "grey20", family = "source_sans_3",
|
size = 5, colour = "grey20", family = "source_sans_3",
|
||||||
max.overlaps = 30, segment.size = 0.25
|
max.overlaps = 30, segment.size = 0.25
|
||||||
) +
|
) +
|
||||||
|
|
@ -245,3 +252,29 @@ fig_county <- ggplot(combined, aes(x = share, y = county, fill = cluster_label))
|
||||||
ggsave("ppt/figures/slide4_county.png", fig_county,
|
ggsave("ppt/figures/slide4_county.png", fig_county,
|
||||||
width = 14, height = 9, dpi = 150)
|
width = 14, height = 9, dpi = 150)
|
||||||
message("Saved: ppt/figures/slide4_county.png")
|
message("Saved: ppt/figures/slide4_county.png")
|
||||||
|
|
||||||
|
# Standalone: absolute population stacked bars (bar length = total population)
|
||||||
|
fig_county_abs <- ggplot(county_pop,
|
||||||
|
aes(x = pop, y = county, fill = cluster_label)) +
|
||||||
|
geom_col(width = 0.8) +
|
||||||
|
geom_text(
|
||||||
|
aes(label = pop_label),
|
||||||
|
position = position_stack(vjust = 0.5),
|
||||||
|
size = 3.3, family = "source_sans_3", colour = "grey20",
|
||||||
|
check_overlap = TRUE
|
||||||
|
) +
|
||||||
|
scale_fill_manual(values = cluster_palette |> set_names(cluster_labels),
|
||||||
|
name = NULL) +
|
||||||
|
scale_x_continuous(labels = \(x) paste0(round(x / 1e6, 1), "M"),
|
||||||
|
expand = c(0, 0)) +
|
||||||
|
labs(y = NULL, x = "Total population") +
|
||||||
|
theme(
|
||||||
|
axis.text.y = element_text(size = 14),
|
||||||
|
legend.position = "bottom",
|
||||||
|
legend.text = element_text(size = 13)
|
||||||
|
) +
|
||||||
|
guides(fill = guide_legend(nrow = 3))
|
||||||
|
|
||||||
|
ggsave("ppt/figures/slide4_county_abs.png", fig_county_abs,
|
||||||
|
width = 9, height = 9, dpi = 150)
|
||||||
|
message("Saved: ppt/figures/slide4_county_abs.png")
|
||||||
|
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 205 KiB After Width: | Height: | Size: 207 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 212 KiB After Width: | Height: | Size: 214 KiB |
BIN
ppt/figures/slide4_county_abs.png
Normal file
BIN
ppt/figures/slide4_county_abs.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 91 KiB |
Loading…
Add table
Reference in a new issue