R语言 如何调整复杂热图中轴标签的字体大小?

hmae6n7t  于 2023-01-28  发布在  其他
关注(0)|答案(1)|浏览(770)

我正在使用ComplexHeatmap在R中创建一个热图。我在这里重新创建了一个小热图。我无法从文档中找到如何调整x轴上文本的字体大小。

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"))

此代码生成以下内容:

我想调整c("alphabet","xylophone","tornado")文本的字体大小,使其更小。我该怎么做?

i2loujxw

i2loujxw1#

可以使用row_names_gpcolumn_names_gp分别调整y轴和x轴标签。

# 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))

相关问题