Skip to content

Instantly share code, notes, and snippets.

@jokergoo
Last active June 26, 2019 07:06
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/0cb81bf0edb56aec56fe25d8f0f2de21 to your computer and use it in GitHub Desktop.
Save jokergoo/0cb81bf0edb56aec56fe25d8f0f2de21 to your computer and use it in GitHub Desktop.
mat = matrix(0, nrow = 10, ncol = 27)
mat[2, c(1, 2, 3, 13, 14, 15, 17, 23, 25)] = 1
mat[3, c(1, 5, 6, 7, 9, 10, 11, 13, 15, 17, 19, 20, 21, 23, 24, 25)] = 1
mat[4, c(1, 5, 7, 9, 10, 11, 13, 14, 17, 19, 21, 24)] = 1
mat[5, c(1, 2, 3, 5, 6, 7, 9, 11, 13, 17, 19, 20, 23, 25)] = 1
mat[7, c(1, 3, 14, 25, 26, 27)] = 1
mat[8, c(1, 3, 5, 6, 7, 10, 11, 13, 14, 15, 17, 18, 19, 21, 22, 23, 25, 27)] = 1
mat[9, c(1, 2, 3, 5, 7, 9, 11, 14, 17, 18, 19, 21, 23, 25, 26)] = 1
mat[10, c(1, 3, 5, 6, 9, 10, 11, 14, 17, 19, 21, 22, 25)] = 1
mat2 = cbind(mat[1:5, ], mat[6:10, ])
mat2 = mat2[-1, ]
Heatmap(mat2, name = "foo", rect_gp = gpar(col = "white", lwd = 2, type = "none"), cluster_rows = FALSE, cluster_columns = FALSE,
col = c("0" = "white", "1" = "darkgreen"), show_heatmap_legend = FALSE,
cell_fun = function(j, i, x, y, w, h, f) {
for(n in 1:2) {
for(m in 1:2) {
if(mat2[i, j]) {
fill = add_transparency("#4DAF4A", runif(1, min = 0, max = 0.3))
} else {
fill = rand_color(1, luminosity = "light", transparency = 0.8)
}
if( (i == 2 && j == 45) || (i == 2 && j == 10)) {
if(m == 2) {
fill = rand_color(1, luminosity = "light", transparency = 0.8)
}
}
grid.rect(x - 0.5*w + (n-0.5)/2*w, y - 0.5*h + (m-0.5)/2*h,
1/2*w, 1/2*h,
gp = gpar(fill = fill, col = "white"))
}
}
})
@jokergoo
Copy link
Author

image

@jokergoo
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment