How can I set the right font of heatmap to be italic?And some font to be superscripts or subscript below heatmap?

setwd(choose.dir())

options(repos=structure(c(CRAN="The Comprehensive R Archive Network")))
install.packages('psych')
install.packages("reshape2")
library(psych)
library(corrplot)
library(pheatmap)
library(reshape2)

Order<-read.table('nirk_属水平.txt', header = TRUE,
sep = '\t',row.names = 1)

Order<-t(Order)

lihua<-read.table('env_table.txt', header = TRUE,
sep = '\t',row.names = 1)

res<-corr.test(Order, lihua, method = 'spearman',
adjust = 'holm',alpha = 0.05)
rmt<-res$r
pmt<-res$p
mycol<-colorRampPalette(c("blue","white","tomato"))(800)

if (!is.null(pmt)){ssmt <- pmt< 0.01
pmt[ssmt] <-'**'
smt <- pmt >0.01& pmt <0.05
pmt[smt] <- '*'
pmt[!ssmt&!smt]<- ''
} else {
pmt <- F
}

pheatmap(rmt, cluster_rows = F, cluster_cols = F,
display_numbers = pmt,fontsize_number = 12,
number_color = "black", cellwidth = 20,
cellheight = 20,color = mycol)

You can use plotmath expressions in the labels:

library(pheatmap)

rmt <- matrix(rnorm(9), ncol = 3)

pheatmap(rmt,
         labels_row = c(expression(italic(Aaaa)), expression(B^b), expression(C[c])),
         labels_col = c("E","F","G"))

Created on 2024-02-01 with reprex v2.0.2

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.