I'm trying to profit from ggtext's more generous behavior of vectorized input to element_text() to plot multiple subtitles on the same line (see f.e. here).
I'm wondering about the behavior of hjust = c(0, 1) in element_markdown() however, that deviates from the ggplot2-native element_text() function:
library(ggplot2)
gg <- ggplot(data = mtcars, aes(x = disp, y = mpg)) +
geom_line() +
labs(subtitle = c("left-aligned subtitle", "right-aligned subtitle"))
# ggplot2 version
gg +
theme(
plot.subtitle = element_text(hjust = c(0, 1))
)
#> Warning: Vectorized input to `element_text()` is not officially supported.
#> ℹ Results may be unexpected or may change in future versions of ggplot2.

# ggtext
# how I was expecting it to work
gg +
theme(
plot.subtitle = ggtext::element_markdown(hjust = c(0, 1))
)

# how it actually worked
gg +
theme(
plot.subtitle = ggtext::element_markdown(hjust = c(1, 5))
)

Created on 2024-05-14 with reprex v2.1.0
Thanks in advance for any pointers! :)