ggplot标签与abline重叠

时间:2017-04-19 15:02:52

标签: r ggplot2 ggrepel

我使用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中避免这种情况?

enter image description here

以下是数据样本:

 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")

0 个答案:

没有答案