census <- count_imaginary_census(graph)
census_df <- census[, names(census)]
class(census_df) <- "data.frame"
census_summary <- census_df |>
filter(grepl("^\\([0-9]", name)) |>
mutate(error_type = case_when(
grepl("Accurate null", name) ~ "Accurate Null",
grepl("Partial false positive \\(null\\)", name) ~ "Partial FP (Null)",
grepl("Complete false positive \\(null\\)", name) ~ "Complete FP (Null)",
grepl("Partial false negative \\(assym\\)", name) ~ "Partial FN (Asymm)",
grepl("Accurate assym", name) ~ "Accurate Asymm",
grepl("Mixed assym", name) ~ "Mixed Asymm",
grepl("Partial false positive \\(assym\\)", name) ~ "Partial FP (Asymm)",
grepl("Complete false negative \\(full\\)", name) ~ "Complete FN (Full)",
grepl("Partial false negative \\(full\\)", name) ~ "Partial FN (Full)",
grepl("Accurate full", name) ~ "Accurate Full",
TRUE ~ "Other"
))
error_colors <- c("Accurate Null" = "#27ae60", "Accurate Asymm" = "#2ecc71",
"Accurate Full" = "#16a085", "Partial FP (Null)" = "#f39c12",
"Partial FN (Asymm)" = "#e67e22", "Partial FN (Full)" = "#d35400",
"Complete FP (Null)" = "#e74c3c", "Complete FN (Full)" = "#c0392b",
"Partial FP (Asymm)" = "#8e44ad", "Mixed Asymm" = "#9b59b6", "Other" = "#95a5a6")
ggplot(census_summary, aes(x = reorder(error_type, value), y = value)) +
geom_col(aes(fill = error_type), alpha = 0.9, width = 0.8) +
geom_text(aes(label = ifelse(value > 0, value, "")), hjust = -0.1, size = 3.2, fontface = "bold") +
scale_fill_manual(values = error_colors) + coord_flip() +
labs(title = "🎯 Distribution of Perceptual Errors", x = "Error Type", y = "Count") +
guides(fill = "none")