I am trying to create a textbox to accompany a complex visualisation developed in ggplot2.
My code is:
library(ggplot2)
library(ggtext)
text<-"How to read this infographic?<br>
<br>
There is a block of text here that goes over<br>
several lines<br>
<img src='~/pics/icons8-forest-50.png' width='20' float= 'left' /> There is a very very very very very very long sentence here <br>
and more text here.<br>"
textbox<-ggplot(data = data.frame(x = 0:1, y = 1:10)) +
labs(subtitle = text) +
theme_void() +
theme(plot.subtitle = ggtext::element_markdown(size=8,
hjust = 0,
halign = 0,
colour="white"),
plot.margin = unit(c(0,0,-2,0), "lines"),
plot.background = element_rect(fill = "black",
colour = "black"),
plot.title.position = "plot"
)
The output I get looks like the picture below
I would like to improve the visual result by
- making both lines that follow the picture (There is a very very very very very very long sentence here and more text here. )fit nicely on the right side of the picto, and
- fully justify the text in the textbox overall.