【问题标题】:pheatmap: change text colorpheatmap:更改文本颜色
【发布时间】:2019-01-11 03:50:09
【问题描述】:

如何更改 pheatmap 中的文本颜色?我尝试了以下方法,但它不会更改轴文本和标签,但它不起作用

par( col.lab="#FFFFFF", fg="#FFFFFF", col.main="#FFFFFF", col.axis="#FFFFFF", cex.main=2, cex=2)
pheatmap(heat_data, cluster_rows = FALSE, gaps_row = c(3), cellwidth=35, cellheight=35, fontsize = 25)

【问题讨论】:

    标签: r heatmap pheatmap


    【解决方案1】:

    这就是答案。该代码修改了 x 和 y 标签的颜色和字体大小以及树状图的颜色和线宽。颜色设置为白色,但您可以将其更改为其他颜色。

    p = pheatmap(heat_data, cluster_rows=F,  gaps_row = 3, 
                cellwidth=45, cellheight=45, fontsize = 20, angle_col = "90", legend=TRUE,legend_breaks=c(40, 20, 0, -20, -40, -60),
                 legend_labels=c(40, 20, " 0", -20, -40, -60), annotation_row = NULL,
                annotation_legend = FALSE, labels_row = NULL, labels_col=NULL, 
                annotation_names_row = F, annotation_names_col = F, annotation_colors  = ann_colors, dist="euclidean", 
                col=COLS, scale="none", show_rownames = T, show_colnames = T)
    my_gtable = p$gtable
    
    my_gtable$grobs[[3]]$gp=gpar(col="#ffffff", fontsize=20)# assuming that the xlabels are in the third grob
    my_gtable$grobs[[4]]$gp=gpar(col="#ffffff", fontsize=20)# assuming that the ylabels are in the fourth grob
    my_gtable$grobs[[1]]$gp=gpar(col="#ffffff", lwd=2) # change the color of the dendrogram and set the linewidth to 2
    my_gtable$grobs[[5]]$gp=gpar(col="#ffffff", fontsize="20", just="center") # legend
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-25
      • 2016-11-07
      • 2012-12-15
      • 2017-12-09
      相关资源
      最近更新 更多