Open SchmidtPaul opened 2 years ago
StackOverflow suggests interest in this: https://stackoverflow.com/questions/73384281/justify-multiline-text-in-ggplot2-title-subtitle-caption-geom-text-etc
Also, see this: https://twitter.com/nrennie35/status/1599817763912286208
Found a solution using {marquee} instead. See updated Stackoverflow Post above or this post on LinkedIn
[This issue is basically a copy of this stackoverflow post I created first to make sure I am not missing an obvious (alternative) solution.]
I would like to justify (not just align!) multiline text in my ggplots, i.e. mostly title, subtitle, caption and annotations via
geom_text()
etc.Justified Text
To be clear, by "justified text" I mean adding space between words so that both edges of each line are aligned with both margins. The last line in the paragraph is aligned left. In the following image it would be the format on the right, highlighted in yellow:
reprex
Below is a reproducible example trying it with both
{ggplot2}
and{ggtext}
. As you can see, I can only think of usinghjust=
(andhalign=
with{ggtext}
) but they only align and do not justify multiline text.Created on 2022-08-23 with reprex v2.0.2