Annotate Multiple Lines of Text to ggplot2 Plot in R (Example) | Add Label | Split String with '\n'

preview_player
Показать описание
R code of this video:

y = 4:9)

library("ggplot2") # Load ggplot2

ggp <- ggplot(data, aes(x, y)) + # Create ggplot2 plot without text
geom_point()
ggp # Draw ggplot2 plot without text

ggp + # Add text in one line
annotate("text",
x = 4.5,
y = 6,
label = "This is my text!")

ggp + # Add text in multiple lines
annotate("text",
x = 4.5,
y = 6,
label = "This is\nmy text!")

Follow me on Social Media:
Рекомендации по теме
Комментарии
Автор

Always interesting and very useful short videos. Thanks.

epoxiconazole
Автор

Thanks Joachim! Indeed it is very useful

fabiodagostino
join shbcf.ru