Marc Kupietz | 899ba2a | 2022-03-17 21:50:22 +0100 | [diff] [blame^] | 1 | #!/bin/env Rscript |
| 2 | library(tidyverse) |
| 3 | library(idsThemeR) # install_git("https://korap.ids-mannheim.de/gerrit/IDS-Mannheim/idsThemeR") |
| 4 | library(extrafont) |
| 5 | |
| 6 | df <- read_tsv("performance.tsv") |
| 7 | df %>% |
| 8 | fill(Tool) %>% |
| 9 | mutate(order_by = pmax(.[[6]], .[[7]], na.rm = TRUE)) %>% |
| 10 | filter(Tool!="wc", !is.na(order_by)) %>% |
| 11 | pivot_longer(cols=c(7, 6)) %>% |
| 12 | mutate(name=str_replace_all(name, ".*[^0-9]([0-9]+)x.*", "\\1 × Effi")) %>% |
| 13 | mutate(tool = paste0(Tool, if_else(is.na(Model), "", paste0(" (", Model, ")")))) %>% |
| 14 | { df2 <<- . } %>% |
| 15 | mutate(Tool= factor(tool) %>% fct_reorder(order_by)) %>% |
| 16 | ggplot(aes(x=Tool, y=value, fill=name )) + # forcats::fct_rev(name) to reorder x1 and x10 |
| 17 | geom_col(position="dodge") + |
| 18 | labs(x="Tokens / ms", y= NULL, fill = "test corpus") + |
| 19 | coord_flip() + |
| 20 | theme_ids(style="light") + |
| 21 | theme(legend.position = c(0.8, 0.2)) + |
| 22 | scale_fill_ids(palette = "ids") |
| 23 | |
| 24 | ggsave("tok_perf.png", width = 70 * .pt, height = 50 *.pt, units = "mm", dpi = 600) |
| 25 | ggsave("tok_perf.pdf", device = cairo_pdf, width = 70 * .pt, height = 50 *.pt, units = "mm", dpi = 600) |
| 26 | ggsave("tok_perf.svg", width = 70 * .pt, height = 50 *.pt, units = "mm", dpi = 600) |