R语言 ComplexHeatmap 包绘图:图例标题位置设置

本文将介绍使用 R 语言 ComplexHeatmap 包绘制热图时,如何设置图例标题的位置。

代码示例

pheatmap(spe_new,
         name = 'Relative abundance of community (%)',
         legend_breaks= bk,
         legend_labels = c('0', '1.51', '4.3', '12.2', '35.33'),
         cluster_cols =F,
         cluster_rows =T,
         col = colorRampPalette(colors = c('navy','white', 'firebrick3'))(50),
         heatmap_legend_param = list(
           legend_direction = 'horizontal', 
           title_position = 'topcenter',
           legend_width = unit(6, 'cm')))

设置图例标题位置

可以使用 heatmap_legend_param 参数中的 title_gp 选项来设置图例标题的位置和样式。

heatmap_legend_param = list(
  legend_direction = 'horizontal', 
  title_position = 'bottom',
  legend_width = unit(6, 'cm'),
  title_gp = gpar(fontsize = 12, fontface = 'bold', margin = unit(c(0, 0, 0.5, 0), 'cm'))
)

其中,title_position 选项设置图例标题的位置,可以选择 'top'、'left'、'right' 或 'bottom'。title_gp 选项用于设置图例标题的样式,可以设置字体大小、加粗和边距等参数。

R语言 ComplexHeatmap 包绘图:图例标题位置设置

原文地址: https://www.cveoy.top/t/topic/nUwC 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录