John-Henry
John-Henry

Reputation: 1817

Rendering `%` using element_markdown()

How can I keep the % symbol in the title?

library(ggtext)
library(ggplot2)

ggplot(mtcars, aes(cyl, mpg)) +
  geom_col() +
  ggtitle("%") +
  theme(plot.title = element_markdown())

Created on 2022-01-28 by the reprex package (v2.0.1)

Upvotes: 0

Views: 137

Answers (1)

chemdork123
chemdork123

Reputation: 13863

You can just add a space before and the character will display correctly. Although there is a space, the formatting of the title will ignore this:

ggplot(mtcars, aes(cyl, mpg)) +
  geom_col() +
  ggtitle(" %") +
  theme(plot.title = element_markdown())

enter image description here

Upvotes: 1

Related Questions