Error rendering spaces in bold title using ggtext and ggplot2

912 views Asked by At

I just updated my R to version 4.2. Ggtext, which was working fine until then now erase white spaces between words if the text is bold. I found a very similar question on RStudio forum but not a solution for me.

A reproducible example would be as follows (although maybe not that reproducible in other R versions, for it did work fine for me until this morning).

library(ggplot2)
library(ggtext)

p <- ggplot() +
  geom_blank() +
  labs(title = "A title with some words") +
  theme(plot.title = element_textbox_simple(
        face = "bold"))

p

enter image description here

And without bold:

library(ggplot2)
library(ggtext)

p <- ggplot() +
  geom_blank() +
  labs(title = "A title with some words") +
  theme(plot.title = element_textbox_simple())

p

enter image description here

1

There are 1 answers

5
Quinten On

You can just use **bold text** to get your text bold:

library(ggplot2)
library(ggtext)

p <- ggplot() +
  geom_blank() +
  labs(title = "**A title with some words**") +
  theme(plot.title = element_textbox_simple())

p

Output:

enter image description here