【发布时间】:2021-08-28 10:17:54
【问题描述】:
我正在尝试在 R 中旋转 ggplot 上的注释,类似于 this question,但使用带有背景的标签几何图形。
将适用于geom = "text" 或geom_text 的代码与geom = 'label' 或geom_label 一起使用会导致注释未旋转。
fake = data.frame(x=rnorm(100), y=rnorm(100))
ggplot(data = fake, aes(x = x, y = y)) +
geom_point() +
geom_vline(xintercept = -1, linetype = 2, color = "red") +
# annotate(geom = "text", x = -1, y = -1, label = "Helpful annotation", color = "red",
# angle = 90)
annotate(geom = "label", x = -1, y = -1, label = "Helpful annotation", color = "red",
angle = 90)
文本以白色背景显示,但没有旋转。
是否有其他方法可以旋转标签?
【问题讨论】:
-
geom_label()与annotate(geom = "label"...参数相同,不支持旋转。你可以使用ggtext::geom_richtext()。它使用相同的参数,在本例中为angle。