I am using ggtext's element_markdown
to modify a subtitle, and to add color to one word, that is in a plot_annotation
layer. My code is as follows:
p1 + p1 + plot_layout(nrow = 2, heights = c(4, 1.8)) +
plot_annotation(title = "The Rise of Electric Charging",
# Using inline html to change the color
subtitle = "Examining the increase in <span style='color:#668F82;'>electric charging</span> stations over time.") &
theme(plot.title = element_text(color = "White", size = 30, family = "Comfortaa", face = "bold"),
plot.subtitle = element_markdown(color = "White", size = 15, family = "Comfortaa", face = "bold", margin = margin(10, 0, 5, 0, "mm")),
plot.background = element_rect(fill = "#2A2D34", colour = "#2A2D34"))
While this works, it expands the spacing between words/letters, as such:
Compare this to when the text is just an element_text
item:
I'm wondeirng if anyone might have insights into why this is happening? For reference, when adding a title to the indivudal plots, the same issue occurs. However, in other files that I am working from, I am able to modify certain words using the same code.