私が見る限りpoint.padding
、 と同じ値を指定することで重複を避けることができますgeom_point(size)
。nudge_y
そして、非常に小さなプラス値を与えることで、上の位置を定義できます。
library(dplyr)
## an example data (delete duplicated data)
iris2 <- iris %>% distinct(Sepal.Length, Sepal.Width, .keep_all = T)
g <- ggplot(iris2[1:20,], aes(Sepal.Length, Sepal.Width)) + geom_point(pch=1, size=8)
g + geom_text_repel(aes(label=Species), segment.color=NA,
point.padding = unit(8, "points"), nudge_y = 1.0E-6)
[編集]
ラベルにポイントの位置を与える
と思いbox.padding = unit(-0.5, "lines")
ます(ただし、おそらく大文字に基づいています)。
iris2$Species <- as.character(iris2$Species)
iris2[7,5] <- "ABCDEFG"
g2 <- ggplot(iris2[1:20,], aes(Sepal.Length, Sepal.Width)) + geom_point(pch = 1, size = 8)
g2 + geom_text_repel(aes(label=Species), segment.color=NA, box.padding = unit(-0.5, "lines"))
