Files
tso-paper-eval/figures/fig_timeseries.R
T
2026-05-27 21:00:28 +02:00

38 lines
1.7 KiB
R

#!/usr/bin/env Rscript
source("common.R")
parser <- fig_parser(description = "First-flow packet timeseries")
parser$add_argument("--xmin", type = "double", default = 100.0)
parser$add_argument("--xmax", type = "double", default = 105.0)
args <- parser$parse_args()
bins <- read_csv(file.path(args$data, "firstflow_bins.csv"), show_col_types = FALSE) %>%
group_by(solution) %>%
mutate(t_ms = t_ms - min(t_ms)) %>%
ungroup() %>%
filter(t_ms >= args$xmin, t_ms <= args$xmax) %>%
prepare_solution()
pacing_label <- SOLUTION_LABELS[["tso-pacing"]]
back <- bins %>% filter(solution == pacing_label)
front <- bins %>% filter(solution != pacing_label)
p <- ggplot() +
geom_area(data = back, aes(x = t_ms, y = packets, fill = solution),
alpha = 0.22, show.legend = FALSE) +
geom_line(data = back, aes(x = t_ms, y = packets, colour = solution,
linetype = solution), linewidth = 0.9, key_glyph = "rect") +
geom_line(data = front, aes(x = t_ms, y = packets, colour = solution,
linetype = solution), linewidth = 0.9, key_glyph = "rect") +
scale_colour_manual(values = LABEL_COLORS, breaks = names(LABEL_COLORS)) +
scale_fill_manual(values = LABEL_COLORS, breaks = names(LABEL_COLORS)) +
scale_linetype_manual(values = LABEL_LINETYPES, breaks = names(LABEL_LINETYPES)) +
scale_x_continuous(breaks = seq(args$xmin, args$xmax, 1)) +
scale_y_continuous(breaks = seq(0, 45, 5), limits = c(0, 45)) +
labs(x = "Time elapsed (ms)", y = paste0("Packets per 50 ", label_us(), " bin")) +
theme_paper() +
theme(legend.text = element_text(size = rel(0.8)),
legend.key.size = unit(6, "pt"))
save_figure(p, args)