Description
Currently, the default alignment for titles and subtitles is against the panel of a plot but not the plot itself. In most cases this is absolutely fine, however, where a plot has very long labels on the y axis (x axis if you have done coord-flip) titles will appear quite some way away from the left hand-side of the plot - see the two example plots below.
We can adjust the positioning of titles with the hjust argument, although positioning is dependent on title length and this can be tedious - especially if you are auto-generating lots of plots where the title changes.
Is it possible to set the default alignment of titles and subtitles against the plot instead of against the panel? For example, in Plot 2 this would mean the title being in line with the lefthand most character of the y axis (the A in "And another really really long category name").
Apologies if this issue has been raised before - I couldn't see that it had.
Brief description of the problem
``` r
library(tidyverse)
data <- tibble(
long_name = c("A really really long category name",
"Another really really long category name",
"And another really really long category name"),
short_name = c("A", "B", "C"),
values = c(200, 300, 500)
)
ggplot(data, aes(x = short_name, y = values)) +
geom_bar(stat = "identity") +
coord_flip() +
labs(title = "My awesome title goes here...") +
theme(axis.title.x = element_blank(),
axis.title.y = element_blank())
ggplot(data, aes(x = long_name, y = values)) +
geom_bar(stat = "identity") +
coord_flip() +
labs(title = "My awesome title goes here...") +
theme(axis.title.x = element_blank(),
axis.title.y = element_blank())
Created on 2019-04-20 by the reprex package (v0.2.1)