【发布时间】:2021-01-30 20:03:25
【问题描述】:
我正在努力改变 ggplot 中 geom_point 中几个点标签的位置。到目前为止,我的代码:
p <- ggplot(all_short_filled, aes(x=Modernization, y=Passionate_love)) +
geom_point(size=2)+geom_abline(intercept = 0.965830, slope = -0.001127)+ theme_bw()
p1 <- p + geom_text(label=all_short_filled$Country, position = position_dodge(width = 1),
vjust = -0.5)
p1
它给了我这样的东西: 我想更改一些重叠标签的位置(例如俄罗斯和塞尔维亚,或荷兰和比利时,例如,塞尔维亚的标签将位于点下方,而不是上方)。请发送帮助:-)
【问题讨论】:
-
看看
ggrepel包。 -
嘿马库斯,我做到了。但结果远非完美(事实上,没有排斥更好):)
-
对于这些国家/地区,您可以将
all_short_filled$Country设置为NA或""。然后为他们创建第二个数据集并添加另一个geom层:geom_text(data = countries_belowdot, ..., vjust = 1)