标记点后,我应用了一条水平线,但丢失了标签-如何纠正?

时间:2019-04-28 11:33:37

标签: r ggplot2

我标记了散点图中的点,并使用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)

0 个答案:

没有答案