timing_figure.R 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. library(dplyr)
  2. library(readr)
  3. library(tidyr)
  4. library(forcats)
  5. library(ggplot2)
  6. theme_set(theme_bw())
  7. timings <- read_csv("n1_timings.csv") %>%
  8. mutate(paper = fct_rev(factor(paper, levels=paper)))
  9. timings_long_period1 <- timings %>%
  10. pivot_longer(c(start, end), names_to="type", values_to="x")
  11. timings_long_period2 <- timings %>%
  12. pivot_longer(c(period2_start, period2_end), names_to="type", values_to="x")
  13. timing_pl <- timings_long_period1 %>%
  14. ggplot() +
  15. geom_rect(
  16. aes(xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax),
  17. fill="steelblue3", alpha=0.3,
  18. data=tibble(xmin=120, xmax=200, ymin=-Inf, ymax=Inf)
  19. ) +
  20. geom_line(aes(x = x, y = paper), linewidth=4) +
  21. geom_line(aes(x = x, y = paper), linewidth=4, data=timings_long_period2, colour="grey60") +
  22. labs(
  23. x = "Latency (ms)",
  24. y = NULL
  25. ) +
  26. scale_x_continuous(breaks = seq(120, 270, 20))
  27. ggsave("n1_timing.png", timing_pl, width=6.5, height=3.25, device="png", type="cairo", dpi=600)
  28. ggsave("n1_timing.pdf", timing_pl, width=6.5, height=3.25, device="pdf")