Remove ggplot title and caption indentation

You can use the theme parameters plot.title.position and plot.caption.position. See ?theme:

Alignment of the plot title/subtitle and caption. The setting for plot.title.position applies to both the title and the subtitle. A value of "panel" (the default) means that titles and/or caption are aligned to the plot panels. A value of "plot" means that titles and/or caption are aligned to the entire plot (minus any space for margins and plot tag).

So using

  theme(
    plot.title.position = "plot",
    plot.caption = element_text(hjust = 0),
    plot.caption.position = "plot",
    plot.background = element_rect(color = 'black', size = 0.5)
)

you get what you want:

3 Likes