123456789101112131415161718192021222324252627282930313233343536373839 |
- # library(extrafont)
- library(showtext)
- font_add(family = "Helvetica", regular = "Helvetica.ttf")
- showtext_auto()
- library(svglite)
- axis_linewidth <- 0.4
- theme_set(
- theme_classic(base_family = "Helvetica") +
- theme(
- plot.title = element_text(size=10, hjust=0.5),
- text = element_text(size=8, family="Helvetica", colour="black"),
- plot.tag = element_text(face="bold", size=10),
- plot.margin = margin(1,2,1,2, "pt"),
- axis.line = element_line(colour = "black", linewidth=axis_linewidth),
- axis.ticks = element_line(colour = "black", linewidth=axis_linewidth),
- axis.text = element_text(colour="black", size=8),
- legend.text = element_text(colour="black", size=8),
- legend.title = element_text(colour="black", size=9),
- axis.title = element_text(colour="black", size=9),
- strip.background = element_blank(),
- strip.text = element_text(size = 9)
- )
- )
- # measure_cols <- c("Jaccard Distance"="#CD8A00", "Wasserstein Distance"="#0043CD")
- measure_cols <- c("Jaccard Distance"="#eb6c00ff", "Wasserstein Distance"="#2b73bcff")
- measure_cols_light_rgb <- col2rgb(measure_cols) * 0.4 + matrix(rep(255, 6), nrow=3) * 0.6
- measure_cols_light <- apply(measure_cols_light_rgb, MARGIN=2, function(x) rgb(t(x), maxColorValue=255))
- # function for interpolating between two colours with n equally spaced colours
- interpolate_hex <- function(a, b, n=4) {
- k <- seq(0, 1, length.out=n)
- a_cols <- matrix(rep(col2rgb(a), n), ncol=n)
- b_cols <- matrix(rep(col2rgb(b), n), ncol=n)
- k_cols <- t(matrix(rep(k, 3), nrow=n))
- c_cols <- a_cols * k_cols + b_cols * (1-k_cols)
- apply(c_cols, MARGIN=2, function(x) rgb(t(x), maxColorValue=255))
- }
|