Hugo
Hugo

Reputation: 11

Single spaces are displayed as double spaces after using element_markdown() in plot.title

I'm having an issue similar to this person's: (ggtext creates excessive white space between subtitle and title). This is happening in all cases in which I try to create a figure using ggplot2 (bar charts, maps...). Here is a reprex:


df <- tibble::tribble(
                          ~municipio,   ~pop,    ~Porte,
                     "Abdon Batista",  2630L,   "Micro",
                      "Abelardo Luz", 17717L, "Pequeno",
                        "Agrolandia", 10272L, "Pequeno",
                        "Agronomica",  5306L, "Pequeno",
                         "Agua Doce",  7132L, "Pequeno",
                  "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()) 

My output has spacing issues in the title, as you can see here: barplot with spacing error. Any clues as to what might be happening here? I need to have the first word in bold typeface, but whenever I use element_markdown(), the spacing goes all out of whack (this doesn't happen if I just leave the title as is).

Upvotes: 1

Views: 405

Answers (0)

Related Questions