Home > Mobile >  Are there unicode characters for superscript C and Z?
Are there unicode characters for superscript C and Z?

Time:10-07

I am interested in creating a label for ggplot that includes non-standard characters and glyphs. In particular, I am interested in printing BETA^WAZ, BETA^DDC, i.e. where the BETA is the Greek glyph and WAZ and DDC are superscript capitals. Based on the guide here and other resources I have come up with the following:

paste0("Corr(\u03B2", "\u1D42", "\u1D2C", "\u2C6B", ", ", "\u03B2", "\u1D30", "\u1D30", "\uA7FD", ")"))

However, this is not the correct C character. In addition, there does not appear to exist a unicode superscript capital Z. Does anyone know of a resource that would have such a character?

EDIT: I may be mistaken but bquote() does not appear to provide what I'm looking for either; for example, see dummy code below, which does not produce the desired label:

data <- data.frame(x = c(0, 1, 2, 3, 4),
y = c(0, 1, 2, 3, 4))

plot <- ggplot(data, aes(x = x, y = y))  
  geom_line()  
  xlab(paste0("Corr(", bquote(beta^WAZ), ", ", bquote(beta^DDC), ")"))

CodePudding user response:

The answer in the @thelatemail's comment above didn't render correctly on my system, so here is another potential solution using bquote():

library(ggplot2)
data <- data.frame(x = c(0, 1, 2, 3, 4),
                   y = c(0, 1, 2, 3, 4))

ggplot(data, aes(x = x, y = y))  
  geom_line()  
  xlab(bquote("Corr(\u03B2" ^WAZ~", \u03B2" ^DDC~")"))

Created on 2022-10-07 by the reprex package (v2.0.1)

  • Related