【发布时间】:2016-08-27 00:51:20
【问题描述】:
我开始学习 ggplot2 已经 3 天了。我正在阅读http://docs.ggplot2.org/current/geom_text.html 的手册,以了解如何使文本与底层几何图形不重叠。
这就是我所做的:
df <- data.frame(trt = c("a", "b", "c"), resp = c(2, 3, 4))
ggplot(df, aes(resp, trt)) +
geom_point() +
geom_text(aes(label = resp , nudge_y = 2, nudge_x = 2))
我尝试使用 nudge_x 和 nudge_y,但似乎没有任何反应。
无论如何我们可以解决这个问题吗?另外,nudge_x 和 nudge_y 有什么用?我不是从手册中得到它。
【问题讨论】:
-
将它们移出
aesthetic,并选择合理的值..geom_text(aes(label = resp) , nudge_y = 0.5, nudge_x = 0.25)