Last active
January 8, 2022 19:17
-
-
Save jokergoo/97afe74b6634bcc793e342633d127f48 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(COVID19) | |
library(ComplexHeatmap) | |
library(circlize) | |
library(spiralize) | |
library(RColorBrewer) | |
spiral_initialize_by_time(xlim = c("2020-01-02", "2022-01-07"), | |
vp_param = list(x = unit(0, "npc"), width = unit(0.9, "snpc"), height = unit(0.9, "snpc"), just = "left")) | |
country = c("DE", "FR", "ES", "GB", "US") | |
col = brewer.pal(length(country), "Set1") | |
lgd_list = NULL | |
for(i in seq_along(country)) { | |
spiral_track(height = 0.18, background = FALSE) | |
x = covid19(country = country[i]) | |
x = x[!is.na(x$confirmed), ] | |
x$daily_increased = diff(c(0, x$confirmed)) | |
x$daily_increased[x$daily_increased < 0] = 0 | |
x$date = as.Date(x$date) | |
lt = spiral_horizon(x$date, x$daily_increased, use_bar = TRUE, pos_fill = col[i]) | |
lgd_list = c(lgd_list, list(horizon_legend(lt, title = country[i]))) | |
} | |
spiral_text(as.POSIXlt("2021-01-15") + months(1:12), y = 1.5, month.name[c(2:12, 1)], | |
facing = "inside", nice_facing = TRUE) | |
spiral_text("2020-01-01", 0.5, "2020", gp = gpar(fontsize = 8)) | |
spiral_text("2021-01-01", 0.5, "2021", gp = gpar(fontsize = 8)) | |
spiral_text("2022-01-01", 0.5, "2022", gp = gpar(fontsize = 8)) | |
lgd = packLegend(list = lgd_list, max_height = unit(8, "in")) | |
draw(lgd, x = unit(1, "npc") + unit(5, "mm"), just = "left") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment