Align Text to Line in ggplot2 Plot in R (Example) | geom_vline & annotate | Vertical & Horizontal

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

y = 1:6)

library("ggplot2") # Load ggplot2

ggp <- ggplot(data, aes(x, y)) + # ggplot2 scatterplot without line & text
geom_point()
ggp

ggp + # Draw line and text
geom_vline(xintercept = 3.5) +
annotate("text",
x = 3.5,
y = 3,
angle = 90,
label = "right-aligned text\n") +
annotate("text",
x = 3.5,
y = 3,
angle = 90,
label = "\nleft-aligned text")

Follow me on Social Media:

Рекомендации по теме
Комментарии
Автор

How would you change the font family of the text? Say to Times New Roman?

douglasmainhart
welcome to shbcf.ru