can International Phonetic Alphabet (IPA) render as title in ggplot2 PDF Output?

can International Phonetic Alphabet (IPA) render as title in ggplot2 PDF output?

library(ggplot2)
ggplot() +
    labs(title =  "I want to use <U+0282> in title.")

It seems successful, but the new problem is how to convert "<U+0282>" to "\U00000282" ?

library(ggplot2)

ggplot(iris, aes(Sepal.Width, Sepal.Length)) +
  geom_point() +
  labs(title =  "I want to use \U00000282 ")

Hi @perlatex,
They are just strings so you can do some simple manipulation to get them into format suitable for plotting:

suppressPackageStartupMessages(library(tidyverse))

# Can use the 4 digit code
ggplot(iris, aes(Sepal.Width, Sepal.Length)) +
  geom_point() +
  labs(title =  "I want to use \U0284 ")

# So, how to convert?
old_strings <- c("<U+0282>","<U+0283>","<U+2C71>")

tmp <- gsub("[<>+]", "", old_strings)
tmp2 <- gsub("U", "0x", tmp)         # This prefix means 'interpret as base 16'

new_strings <- intToUtf8(tmp2, multiple=TRUE)

ggplot(iris, aes(Sepal.Width, Sepal.Length)) +
  geom_point() +
  labs(title =  paste0("I want to use: ", new_strings[1]),
       subtitle = paste0("And these: ", new_strings[2],"  ", new_strings[3]))

Created on 2022-02-25 by the reprex package (v2.0.1)

1 Like

perfect! Thank you very much for your help

This topic was automatically closed 7 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.