Search code examples
rlabelsuperscriptr-corrplot

How to include "superscript +" in corrplot label?


I want to include "+" as a superscript in corrplot label. I was able to find ways to put subscript but not superscript. Any help would be really appreciated. Here is a simple example I found and I changed a little to make it relevant to my problem. R corrplot change data labels

I want a^+(+ as superscript) and a^2(a-squared) as 4th and 5th column names.

M <- cor(mtcars)[1:5,1:5]
colnames(M) <- c("alpha", "beta", ":alpha+beta", ":a^[+]", ":a^[2]")
rownames(M) <- c("alpha", "beta", NA, "$a[0]", "$ a[beta]")
corrplot(M)

Solution

  • Try to put it in single quotes:

    library(corrplot)
    #> corrplot 0.84 loaded
    M <- cor(mtcars)[1:5,1:5]
    colnames(M) <- c("alpha", "beta", ":alpha+beta", ":a^'+'", ":a^2")
    rownames(M) <- c("alpha", "beta", NA, "$a[0]", "$ a[beta]")
    corrplot(M)
    

    Created on 2020-07-22 by the reprex package (v0.3.0)