在 plot.title 中使用 element_markdown() 后,单个空格显示为双空格

问题描述

我遇到了与此人类似的问题:(ggtext creates excessive white space between subtitle and title)。在我尝试使用 ggplot2(条形图、地图...)创建图形的所有情况下都会发生这种情况。这是一个reprex:


df <- tibble::tribble(
                          ~municipio,~pop,~Porte,"Abdon Batista",2630L,"Micro","Abelardo Luz",17717L,"Pequeno","Agrolandia",10272L,"Agronomica",5306L,"Agua Doce",7132L,"Aguas de Chapeco",6379L,"Pequeno"
                  )

df %>% 
  ggplot(aes(x = Porte,fill = Porte)) +
  geom_bar() +
  labs(x = " ",y = " ",title = "**Gráfico 1** - Porte populacional dos municípios catarinenses",caption = "Fonte: IBGE (2016)") + 
  ggthemes::theme_tufte()+
  theme(plot.caption = element_text(hjust = 0),plot.title = element_markdown()) 

我的输出标题中有间距问题,正如您在此处看到的:barplot with spacing error。关于这里可能发生什么的任何线索?我需要使用粗体字体的第一个单词,但是每当我使用 element_markdown() 时,间距都会变得不正常(如果我只是保持标题不变,则不会发生这种情况)。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)