我标记了散点图中的点,并使用geom_text_repel
。一切正常,但是当我想添加一条水平线geom_hline
时,我得到了,但是标签掉了。如何同时保留两个几何?
library(ggrepel)
library(tidyverse)
data <- head(mtcars, 30)
data3 <- data2 %>% mutate(model_2 = model) %>% column_to_rownames("model")
head(data3)
情节
p = ggplot(data3,aes(qsec, mpg))+
geom_point()
p + geom_text(data = (data3), aes(label = model_2))
# This separates points that are on top of each other
p + geom_text_repel(data = (data3), aes(label=model_2))
###Works well up to this point ######
# Horizontal line at 25 Text labels are removed????
p + geom_hline(yintercept = 25)