circle_discrete()
Published

October 7, 2025

Circlular plot

library(ggalign)
#> Loading required package: ggplot2
#> ========================================
#> ggalign version 1.1.0.9000
#> 
#> If you use it in published research, please cite: 
#> Peng, Y.; Jiang, S.; Song, Y.; et al. ggalign: Bridging the Grammar of Graphics and Biological Multilayered Complexity. Advanced Science. 2025. doi:10.1002/advs.202507799
#> ========================================
set.seed(123)
# Prepare heatmap matrix
mat <- matrix(
    rnorm(100, mean = 0, sd = 2),
    nrow = 10, ncol = 10,
    dimnames = list(paste0("G", 1:10), paste0("S", 1:10))
)

Construct a circular heatmap layout using ggalign’s grammar

circle_discrete(mat, radial = coord_radial(inner.radius = 0.1)) +

    # add a dendrogram
    align_dendro(aes(color = branch), k = 3L, size = 0.5) +
    scale_color_brewer(palette = "Dark2") +

    # add a heatmap
    ggalign() +
    geom_tile(aes(y = .column_index, fill = value)) +
    scale_fill_viridis_c() +

    # add a single tile for each group
    ggalign(NULL, size = 0.1) +
    geom_tile(aes(y = 1L, fill = .panel)) +
    scale_fill_brewer(palette = "Dark2", guide = "none") &
    theme_no_axes("y")