我使用geom_label_repel
函数以避免重叠的方式排列标签,但是当我向绘图添加回归线时,它本身会重叠标签。
ggplot(globalMetrics, aes(x=globalMetrics$popDensity, y=globalMetrics$turnover)) + geom_point() +
theme_bw() + geom_label_repel(aes(label= rownames(globalMetrics)), size=3) + stat_smooth(method="lm")
有没有办法在ggplot
中避免这种情况?
以下是数据样本:
dput(globalMetrics)
structure(list(popDensity = c(4308, 27812, 4447, 5334, 4662,
2890), turnover = c(2.65, 4.49, 2.37, 2.87, 3.87, 2.95)), .Names = c("popDensity",
"turnover"), row.names = c("label1", "label2", "label3", "label4",
"label5", "label6"), class = "data.frame")