Add absolute comparison plot
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
library(ggplot2)
|
||||
library(dplyr)
|
||||
library(readr)
|
||||
|
||||
# Usage: Rscript combined_comparison.r exp_abspath1 exp_abspath2 ... [resultsdata_file]
|
||||
|
||||
args <- commandArgs(trailingOnly = TRUE)
|
||||
if (length(args) < 1) {
|
||||
stop("Need at least 1 experiment")
|
||||
}
|
||||
|
||||
csv_suffix <- if (grepl("\\.csv$", args[length(args)])) {
|
||||
args[length(args)]
|
||||
} else {
|
||||
"resultsdata.csv"
|
||||
}
|
||||
exp_args <- if (grepl("\\.csv$", args[length(args)])) {
|
||||
args[-length(args)]
|
||||
} else {
|
||||
args
|
||||
}
|
||||
|
||||
all_data <- data.frame()
|
||||
|
||||
for (arg in exp_args) {
|
||||
csv_file <- file.path(arg, csv_suffix)
|
||||
if (!file.exists(csv_file)) {
|
||||
warning(paste("Missing:", csv_file))
|
||||
next
|
||||
}
|
||||
|
||||
df <- read_csv(csv_file, col_types = cols())
|
||||
df$experiment <- basename(arg)
|
||||
all_data <- bind_rows(all_data, df)
|
||||
}
|
||||
|
||||
if (nrow(all_data) == 0) {
|
||||
stop("No data loaded")
|
||||
}
|
||||
|
||||
totals <- all_data |>
|
||||
group_by(experiment, resulttype) |>
|
||||
summarise(faults = sum(faults, na.rm = TRUE), .groups = "drop") |>
|
||||
ungroup()
|
||||
|
||||
marker_order <- c(
|
||||
"OK_MARKER",
|
||||
"FAIL_MARKER",
|
||||
"DETECTED_MARKER",
|
||||
"TIMEOUT",
|
||||
"TRAP",
|
||||
"WRITE_TEXTSEGMENT",
|
||||
"ACCESS_OUTERSPACE",
|
||||
"GROUP1_MARKER"
|
||||
)
|
||||
totals$resulttype <- factor(totals$resulttype, levels = marker_order)
|
||||
|
||||
plot <- ggplot(
|
||||
totals,
|
||||
aes(x = resulttype, y = faults, colour = experiment, group = experiment)
|
||||
) +
|
||||
geom_point(size = 2) +
|
||||
geom_line() +
|
||||
scale_y_log10() +
|
||||
labs(
|
||||
x = "Marker",
|
||||
y = "Faults",
|
||||
title = "Combined Comparison",
|
||||
color = "Experiment"
|
||||
) +
|
||||
theme_minimal() +
|
||||
theme(axis.text.x = element_text(angle = 45, hjust = 1))
|
||||
|
||||
suffix <- gsub("^resultsdata|\\.csv$", "", csv_suffix)
|
||||
outfile <- paste0("injections/combined_comparison", suffix, ".svg")
|
||||
ggsave(outfile, plot = plot, width = 12, height = 6)
|
||||
print(paste("Saved", outfile))
|
||||
@@ -109,7 +109,7 @@ plot <- ggplot(
|
||||
scale_y_log10(name = "Interpreter / C Ratio") +
|
||||
labs(
|
||||
title = sprintf("Ratio Correlation (r = %.4f)", cor_result),
|
||||
color = "Target",
|
||||
color = "Experiment",
|
||||
shape = "Marker"
|
||||
) +
|
||||
theme_minimal() +
|
||||
|
||||
Reference in New Issue
Block a user