point.padding = NA
にすれば、データポイントを避けずにテキストを追加できます。
例:
geom_text_repel(aes(lon, lat, label = "Tokyo"), point.padding = NA)
サンプル
まず、日本地図を準備します。
library(tmap) library(ggplot2) data("World") jpn <- World[World$name == "Japan",] lon <- 139.691809 # 都庁のおおよその経度 lat <- 35.689591 # 都庁のおおよその緯度 p <- ggplot(jpn) + geom_sf() + coord_sf(crs = 6668) + geom_point(aes(lon, lat)) ## CRS 6668: JGD2011
通常のデータポイントを避けたテキスト追加はこちらです。
library(ggrepel) p + geom_text_repel(aes(lon, lat, label = "Tokyo"))

では、point.padding = NA
にし、データポイントを避けずにテキストを追加します。
p + geom_text_repel(aes(lon, lat, label = "Tokyo"), point.padding = NA)

おわりに
今回の記事はヘルプを参考にしました。
# Repel just the labels and totally ignore the data points p + geom_text_repel(point.padding = NA)
geom_text_repelのヘルプ(?geom_text_repel)
では。
—
YouTube: ミサキさん
問い合わせ先
Mail: caprico.aries@gmail.com
Twitter: https://twitter.com/caprico_aries(無言フォローもお気軽に)
コメント