Debian Codegraph @

compression-ratio/plot.R

raw
1 #!/usr/bin/env Rscript
2
3 library(scales)
4 library(ggplot2)
5 library(dplyr)
6 library(tidyr)
7 library(swr)
8 library(png)
9 library(cowplot)
10 library(ggthemes)
11
12 theme1 <- theme(
13 text = element_text(size = 9),
14 axis.text.x = element_text(size = 10),
15 axis.text.y = element_text(size = 10),
16 axis.title = element_text(size = 13),
17 strip.background = element_rect(
18 colour = "grey80",
19 fill = "grey95",
20 size = 0.5
21 ),
22 legend.position = "bottom",
23 legend.spacing.x = unit(0.4, "cm"),
24 )
25
26 df <- read.csv("table.r.tsv", sep = "\t")
27 df$group <- factor(df$group, levels = unique(df$group), ordered = TRUE)
28 df$num <- factor(df$num, levels = unique(df$num), ordered = TRUE)
29
30 p <- ggplot(df, aes(x = k, y = value, color = group)) +
31 # geom_line(aes(y=mean), color="#3e52a1") +
32 geom_smooth(method = loess,
33 se = FALSE,
34 alpha = 0.2 ) +
35 geom_point(aes(shape = group), size = 2) +
36 scale_x_continuous(limits=c(10, 32), breaks = seq(1, 31, by = 4))+
37 geom_vline(xintercept = seq(21,27,2), colour="grey80", linetype=2, size=0.2) +
38 scale_color_colorblind() +
39 facet_grid(. ~ num, scales = "free_y") +
40 xlab("K") +
41 ylab("compression ratio (%)") +
42 ggtitle(NULL) +
43 shenwei356.theme() +
44 theme1
45
46 ggsave(
47 p,
48 file = "cr.jpg",
49 width = 10,
50 height = 4.5,
51 dpi = 300
52 )
53