我正在使用ggtext的element_markdown修改一个字幕,并为一个单词添加颜色,即在plot_annotation层中。我的代码如下:
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"))虽然这样做有效,但它扩大了单词/字母之间的间距,因此:

将其与文本仅为element_text项时进行比较:

我想知道是否有人能洞悉为什么会发生这种事?作为参考,当添加一个标题到土著情节时,也会出现同样的问题。但是,在我正在处理的其他文件中,我能够使用相同的代码修改某些单词。
发布于 2022-08-21 23:35:40
我在这里也有同样的问题,在我的例子中,我能够在两台Mac笔记本上复制这个bug,但是我们也在windows笔记本上测试了它。我们设法通过将R(和RStudio)的图形渲染转换为Ragg来解决Mac上的问题--也许这会有帮助?
https://stackoverflow.com/questions/71324588
复制相似问题