Skip to content

Instantly share code, notes, and snippets.

@jokergoo
Created October 8, 2020 08:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jokergoo/6de1c9c3c765581e3cbe7d48e719b017 to your computer and use it in GitHub Desktop.
Save jokergoo/6de1c9c3c765581e3cbe7d48e719b017 to your computer and use it in GitHub Desktop.
library(circlize)
seed_color = c("1-3" = 2,
"4-6" = 3,
"7-9" = 4,
"10-12" = 5,
"13-16" = 6,
"(Missing)" = "grey")
round_name = c("Champoin",
"Runner-up",
"Final Four",
"Elite eight",
"Sweet sixteen",
"Second round",
"First round")
par(bg = "#bb9c87")
circos.par(track.margin = c(0, 0), gap.degree = 0, start.degree = 270)
circos.initialize("foo", xlim = c(0, 1))
for(tournament_level in rev(sort(unique(tournament$tournament_level)))) {
l = tournament$tournament_level == tournament_level
l[is.na(l)] = FALSE
circos.track(ylim = c(0, 1), panel.fun = function(x, y) {
n = sum(l)
x = runif(n, min = 0.1, max = 0.9)
y = runif(n)
circos.points(x, y, col = seed_color[tournament$seed_group[l]], pch = 16, cex = 0.5)
if(tournament_level != 1) {
circos.text(0, 0.5, toupper(round_name[tournament_level]), facing = "bending.outside")
}
}, track.height = mm_h(6), bg.col = ifelse(tournament_level %% 2 == 1, "#cdb6a0", "#bb9c87"),
bg.border = NA)
}
draw.sector(rou1 = CELL_META$cell.bottom.radius, col = "#cdb6a0", border = "#cdb6a0")
text(0, 0, toupper("Champoin"), cex = 1.2)
circos.clear()
library(ComplexHeatmap)
lgd = Legend(title = "Seed", at = names(seed_color), legend_gp = gpar(col = seed_color),
background = NA, border = NA, type = "points")
draw(lgd, x = unit(1, "cm"), y = unit(1, "npc") - unit(1, "cm"), just = c("left", "top"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment