Figure 1-2
# --- AONF定数の定義 (AONF standard format) ---
AONF_CAPTION <- "Archives from 2026 Onward and Notes for the Future\n2026年以降の記録 | https://ab.cocolog-nifty.com/note/"
########################################################################
# 福岡11区:社民党(SDP)支持層と候補者の同期分析(SDP Focus)
########################################################################
library(ggplot2)
library(dplyr)
##
## 次のパッケージを付け加えます: 'dplyr'
## 以下のオブジェクトは 'package:stats' からマスクされています:
##
## filter, lag
## 以下のオブジェクトは 'package:base' からマスクされています:
##
## intersect, setdiff, setequal, union
library(tidyr)
library(ggrepel)
# 1. データの読み込み
d24 <- read.csv("data11ku_PC_fixed.csv")
d26 <- read.csv("fukuoka11ku2026_merged_a.csv")
# 2. 前処理:2024年 比例区SDP得票率の算出
d24_sdp <- d24 %>%
mutate(Total_24 = CDP + NKP + LDP + JIP + DPP + SDP + JCP + RS + SAN) %>%
transmute(
Municipality = 市町村,
SDP_2024 = SDP / Total_24
)
# 3. 前処理:2026年 各候補者の得票率算出
d26_shares <- d26 %>%
mutate(Total_26 = rowSums(select(., Tsuji, Takeda, Shiki, Inoue, Murakami))) %>%
transmute(
Municipality,
Tsuji = Tsuji / Total_26,
Takeda = Takeda / Total_26,
Shiki = Shiki / Total_26,
Inoue = Inoue / Total_26,
Murakami = Murakami / Total_26
)
# 4. データの結合
combined_sdp <- inner_join(d24_sdp, d26_shares, by = "Municipality")
# 5. 相関係数(同期率)の計算:SDP vs 全候補者
candidates <- c("Tsuji", "Takeda", "Shiki", "Inoue", "Murakami")
sdp_cor <- data.frame(
Candidate = candidates,
Correlation = sapply(candidates, function(c) cor(combined_sdp$SDP_2024, combined_sdp[[c]]))
) %>% arrange(desc(Correlation))
# ----------------------------------------------------------------------
# 可視化 A:SDP同期率ランキング
# ----------------------------------------------------------------------
p1 <- ggplot(sdp_cor, aes(x = reorder(Candidate, Correlation), y = Correlation, fill = Correlation)) +
geom_bar(stat = "identity", width = 0.7) +
geom_text(aes(label = sprintf("%.2f", Correlation)),
hjust = -0.2,
family = "HiraKakuProN-W3",
size = 3.5) +
coord_flip(clip = "off") +
scale_y_continuous(limits = c(-1, 1.2), breaks = seq(-1, 1, 0.5)) +
scale_fill_gradient2(low = "#e74c3c", mid = "white", high = "#3498db",
midpoint = 0, limit = c(-1, 1)) +
labs(title = "Figure 1\nSDP Support Synchronicity (2024 -> 2026)",
subtitle = "2024年社民党比例票と2026年各候補者得票率の相関",
x = "Candidates", y = "Correlation Coefficient",
caption = AONF_CAPTION) +
theme_minimal(base_family = "HiraKakuProN-W3") +
theme(legend.position = "none",
plot.margin = margin(10, 40, 10, 10),
plot.title = element_text(face = "bold", size = 12),
plot.caption = element_text(size = 8, color = "gray30", hjust = 1, lineheight = 1.2))
# ----------------------------------------------------------------------
# 可視化 B:SDP vs 志岐候補(Shiki) 1:1スケール散布図
# ----------------------------------------------------------------------
p2 <- ggplot(combined_sdp, aes(x = SDP_2024, y = Shiki)) +
geom_abline(intercept = 0, slope = 1, linetype = "dotted", color = "gray50") +
geom_smooth(method = "lm", se = FALSE, color = "black", size = 0.8) +
geom_point(color = "#3498db", size = 3, alpha = 0.7) +
geom_text_repel(aes(label = Municipality), family = "HiraKakuProN-W3", size = 3) +
coord_fixed(ratio = 1) +
scale_x_continuous(limits = c(0, 0.2), labels = scales::percent) +
scale_y_continuous(limits = c(0, 0.2), labels = scales::percent) +
labs(title = "Figure 2\nSynchronicity Detail: SDP(2024) vs. Shiki(2026)",
subtitle = "同期率 0.76 ",
x = "2024 SDP Vote Share", y = "2026 Shiki Vote Share",
caption = AONF_CAPTION) +
theme_minimal(base_family = "HiraKakuProN-W3") +
theme(plot.title = element_text(face = "bold", size = 12),
plot.caption = element_text(size = 8, color = "gray30", hjust = 1, lineheight = 1.2))
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
# グラフの出力
print(p1)

print(p2)
## `geom_smooth()` using formula = 'y ~ x'
## Warning: ggrepel: 11 unlabeled data points (too many overlaps). Consider
## increasing max.overlaps

Figure 3
# --- AONF定数の定義 (Saved Informationに基づく) ---
AONF_CAPTION <- "Archives from 2026 Onward and Notes for the Future\n2026年以降の記録 | https://ab.cocolog-nifty.com/note/"
library(ggplot2)
library(dplyr)
library(tidyr)
library(ggrepel)
# 1. データの読み込み
# ファイルはカレントディレクトリに存在することを前提としています
d24 <- read.csv("data11ku_PC_fixed.csv")
d26 <- read.csv("fukuoka11ku2026_merged_a.csv")
# 2. 得票率の算出(社民党軸)
d24_prep <- d24 %>%
mutate(Total_24 = CDP + NKP + LDP + JIP + DPP + SDP + JCP + RS + SAN,
SDP_Share_24 = SDP / Total_24) %>%
select(Municipality = 市町村, SDP_Share_24)
d26_prep <- d26 %>%
mutate(Total_26 = Tsuji + Takeda + Shiki + Inoue + Murakami) %>%
mutate(Tsuji = Tsuji / Total_26,
Murakami = Murakami / Total_26,
Takeda = Takeda / Total_26,
Inoue = Inoue / Total_26,
Shiki = Shiki / Total_26) %>%
select(Municipality, Tsuji, Murakami, Takeda, Inoue, Shiki)
# データの結合と縦長形式への変換(Facet用)
plot_df <- inner_join(d24_prep, d26_prep, by = "Municipality") %>%
pivot_longer(cols = c(Tsuji, Murakami, Takeda, Inoue, Shiki),
names_to = "Candidate", values_to = "Share_26")
# 3. 散布図の可視化
ggplot(plot_df, aes(x = SDP_Share_24, y = Share_26)) +
# 回帰直線の描画
geom_smooth(method = "lm", se = FALSE, color = "gray60", linetype = "dashed", linewidth = 0.5) +
# 自治体ポイント
geom_point(aes(color = Candidate), size = 2.5, alpha = 0.8) +
# 自治体名のラベル
geom_text_repel(aes(label = Municipality), size = 2.5, family = "HiraKakuProN-W3") +
# 候補者ごとにグラフを分割
facet_wrap(~ Candidate, scales = "free_y") +
# AONF標準テーマ (Saved Informationに基づく)
theme_minimal(base_family = "HiraKakuProN-W3") +
theme(legend.position = "bottom",
plot.caption = element_text(size = 8, color = "gray30", hjust = 1, lineheight = 1.2),
strip.background = element_rect(fill = "gray95", color = "white"),
strip.text = element_text(face = "bold")) +
labs(title = "Figure 3\n2024年「社民支持層」の流動性:自治体別散布図",
subtitle = "X軸:2024年社民得票率 / Y軸:2026年各候補者得票率",
x = "2024年 社民票シェア (SDP)",
y = "2026年 候補者個人得票率",
caption = AONF_CAPTION)
## `geom_smooth()` using formula = 'y ~ x'

Figure 4
# --- AONF定数の定義 (Saved Informationに基づく) ---
AONF_CAPTION <- "Archives from 2026 Onward and Notes for the Future\n2026年以降の記録 | https://ab.cocolog-nifty.com/note/"
library(ggplot2)
library(dplyr)
library(tidyr)
# 1. データの読み込み
d24 <- read.csv("data11ku_PC_fixed.csv")
d26 <- read.csv("fukuoka11ku2026_merged_a.csv")
# 2. 前処理:得票率の算出
# 2024年:社会民主党(SDP)シェア
d24_sdp <- d24 %>%
mutate(Total_24 = CDP + NKP + LDP + JIP + DPP + SDP + JCP + RS + SAN,
SDP_Share_24 = SDP / Total_24) %>%
select(Municipality = 市町村, SDP_Share_24)
# 2026年:各候補者シェア
d26_shares <- d26 %>%
mutate(Total_26 = rowSums(select(., Tsuji, Takeda, Shiki, Inoue, Murakami))) %>%
transmute(
Municipality,
Takeda = Takeda / Total_26,
Murakami = Murakami / Total_26,
Shiki = Shiki / Total_26,
Tsuji = Tsuji / Total_26,
Inoue = Inoue / Total_26
)
# データの結合
transfer_df_sdp <- inner_join(d24_sdp, d26_shares, by = "Municipality")
# 3. 回帰分析による「支持継承の強さ(回帰係数)」の算出
models <- list(
Takeda = lm(Takeda ~ SDP_Share_24, data = transfer_df_sdp),
Murakami = lm(Murakami ~ SDP_Share_24, data = transfer_df_sdp),
Shiki = lm(Shiki ~ SDP_Share_24, data = transfer_df_sdp),
Tsuji = lm(Tsuji ~ SDP_Share_24, data = transfer_df_sdp),
Inoue = lm(Inoue ~ SDP_Share_24, data = transfer_df_sdp)
)
transfer_rates_sdp <- data.frame(
Candidate = names(models),
Rate = sapply(models, function(m) coef(m)[2])
)
# 4. 可視化:支持の「吸着度」ランキング
ggplot(transfer_rates_sdp, aes(x = reorder(Candidate, -Rate), y = Rate, fill = Candidate)) +
geom_bar(stat = "identity", width = 0.6) +
geom_hline(yintercept = 0, color = "gray50") +
# AONF標準テーマ
theme_minimal(base_family = "HiraKakuProN-W3") +
theme(legend.position = "none",
axis.text = element_text(size = 9), # 目盛りサイズ指定
plot.caption = element_text(size = 8, color = "gray30", hjust = 1, lineheight = 1.2)) +
scale_fill_brewer(palette = "Set3") + # 社民党のイメージに合わせた配色
labs(title = "Figure 4\n2024年「社民支持層」はどこへ流れたか(推計)",
subtitle = "2024年社会民主党得票率との回帰分析に基づく支持の継承度",
x = "2026年 候補者",
y = "支持継承の強さ (Regression Coefficient)",
caption = AONF_CAPTION)

Figure 5
# --- AONF定数の定義 (AONF format) ---
AONF_CAPTION <- "Archives from 2026 Onward and Notes for the Future\n2026年以降の記録 | https://ab.cocolog-nifty.com/note/"
library(ggplot2)
library(dplyr)
library(tidyr)
library(ggrepel)
# 1. データの読み込み
d24 <- read.csv("data11ku_PC_fixed.csv")
d26 <- read.csv("fukuoka11ku2026_merged_a.csv")
# 2. 前処理:2024年 社民党(SDP)得票率の算出
d24_sdp <- d24 %>%
mutate(Total_24 = CDP + NKP + LDP + JIP + DPP + SDP + JCP + RS + SAN) %>%
transmute(
Municipality = 市町村,
SDP_2024 = SDP / Total_24
)
# 3. 前処理:2026年 武田候補の得票率算出
d26_takeda <- d26 %>%
mutate(Total_26 = rowSums(select(., Tsuji, Takeda, Shiki, Inoue, Murakami))) %>%
transmute(
Municipality,
Takeda_2026 = Takeda / Total_26
)
# 4. データの結合
combined_takeda <- inner_join(d24_sdp, d26_takeda, by = "Municipality")
# 5. 可視化:SDP(2024) vs 武田候補(2026) 1:1スケール散布図
# ※同期率 0.15 / 傾き 5.0超 の「矛盾」を視覚化する
p4 <- ggplot(combined_takeda, aes(x = SDP_2024, y = Takeda_2026)) +
# 理想的な同期ライン (y = x)
geom_abline(intercept = 0, slope = 1, linetype = "dotted", color = "gray50") +
# 回帰直線(急峻な傾きを可視化)
geom_smooth(method = "lm", se = FALSE, color = "black", size = 0.8) +
# データ点
geom_point(color = "darkred", size = 3, alpha = 0.7) +
# 自治体ラベル(大任町などの外れ値を明示)
geom_text_repel(aes(label = Municipality), family = "HiraKakuProN-W3", size = 3) +
# ★重要:縦横スケールを1:1に固定し、0%〜80%の範囲を表示
coord_fixed(ratio = 1) +
scale_x_continuous(limits = c(0, 0.8), labels = scales::percent, expand = c(0,0)) +
scale_y_continuous(limits = c(0, 0.8), labels = scales::percent, expand = c(0,0)) +
labs(title = "Figure 5\nSynchronicity Detail: SDP(2024) vs. Takeda(2026)",
subtitle = "同期率 0.15 / 傾き 5.0超 ",
x = "2024 SDP Vote Share (Proportional Representation)",
y = "2026 Takeda Vote Share (Candidate)",
caption = AONF_CAPTION) +
theme_minimal(base_family = "HiraKakuProN-W3") +
theme(plot.title = element_text(face = "bold", size = 12),
plot.caption = element_text(size = 8, color = "gray30", hjust = 1, lineheight = 1.2))
print(p4)
## `geom_smooth()` using formula = 'y ~ x'
## Warning: ggrepel: 3 unlabeled data points (too many overlaps). Consider
## increasing max.overlaps
