How to use plotmeth in pheatmap title?

47 Views Asked by At

I want to add superscript string,such as "+/-" in the tile in pheatmap.

I tried my best to come up with some ideas but it doesn't work.

Here is my reproducible code:

library(pheatmap) main<- expression(ABC^'+/-') pheatmap(matrix(runif(100,0,1),10,10), main = main)

It can add only the single expression string in the title.

But I want to add other information with a blank line not only the expression information like this:

main<- paste(expression(ABC^'+/-'),"\nABCDEFG")
pheatmap(matrix(runif(100,0,1),10,10),
         main = main)

It is a little bit difficult to me to solve it.

I hope somebody could help me deal with this problem.

Thanks in advance.

######## update:

I tried many methods. But it still doesn't work. It is a little difficult to add special string like "+/-" together.

1

There are 1 best solutions below

0
花落思量错 On BEST ANSWER

Finally, I find a better but not perfect method:

Here is my solution:

pheatmap(mat, 
         main =expression(atop(ABC^'+/-',
                               "ABCDEFG"))

Just use "atop" instead of "\n". Because "\n" doesn't work in an expression function.

I said that it is not perfect because if you want to paste/paste0 any strings which contains with an expression and after it, some information may not express clearly.

For example:

pheatmap(mat, 
         main =expression(atop(ABC^'+/-',
                               paste("ABCDEFG,the total number = ",dim[mat][1],)))

Here the paste() doesn't work because of expression().

So somebody could give me some advice or solution if you are expert in this region.

Or maybe I ignored some information in detail.

Thank in advance.