简体   繁体   中英

How to adjust the font size for axis labels in Complex Heatmap?

I'm using ComplexHeatmap to create a heatmap in R. I have recreated a small heatmap here. I can't figure out from the documentation how to adjust the font size for the text on the x-axis.

a = matrix(1:9, nrow = 3, ncol = 3)
rownames(a) = c("alphabet","xylophone","tornado")
colnames(a) = c("c1","c2","c3")

my_heatmap = ComplexHeatmap::Heatmap(
        matrix = t(a),
        col = RColorBrewer::brewer.pal(9, "RdBu"))

This code produces this:

热图

I want to adjust the font size for the c("alphabet","xylophone","tornado") text so that it is much smaller. How do I do this?

You can use row_names_gp and column_names_gp to adjust y-axis and x-axis labels, respectively.

# if (!requireNamespace("BiocManager", quietly = TRUE))
#       install.packages("BiocManager")
# BiocManager::install("ComplexHeatmap")
#
# library(ComplexHeatmap)
# library(grid)
a = matrix(1:9, nrow = 3, ncol = 3)
rownames(a) = c("alphabet","xylophone","tornado")
colnames(a) = c("c1","c2","c3")

ComplexHeatmap::Heatmap(
  matrix = t(a),
  col = RColorBrewer::brewer.pal(9, "RdBu"),
  column_names_gp = grid::gpar(fontsize = 8),
  row_names_gp = grid::gpar(fontsize = 8))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM