作者简介taoyan:伪码农,R语言爱好者,爱开源。个人博客: https://ytlogos.github.io/library(ggplot2)#使用数据集mtcars演示ggplot(mtcars)+ geom_point(aes(wt, mpg), color="red")+geom_text(aes(wt, mpg, label=rownames(mtcars)))+theme_classic(base_size = 16)可以看到可视化效果不是很好。接下来看看包ggrepel的效果。geom_text_repel()是基于geom_text()library(ggrepel)set.seed(42)ggplot(mtcars)+ geom_point(aes(wt, mpg), color="red")+geom_text_repel(aes(wt, mpg, label=rownames(mtcars)))+theme_classic(base_size = 16)geom_label_repel()geom_label_repel()是基于geom_label(),它将标签置于一个小方框中set.seed(42)ggplot(mtcars)+ geom_point(aes(wt, mpg), color="grey", size=5)+geom_label_repel(aes(wt, mpg, fill=factor(cyl),label=rownames(mtcars)), fontface="bold", color="white",box.padding=unit(0.35, "lines"), point.padding=unit(0
………………………………