如何增加下面的axis.line.y
和下面的蓝色geom_hline
之间的距离?我希望两者之间有空隙,我不希望他们像情节所示那样接吻。
library(tidyverse)
ggplot(mpg, aes(cty, hwy)) +
geom_point() +
geom_hline(yintercept = 25, color = "blue") +
theme_minimal() +
theme(axis.line.y = element_line(color = "black"),
axis.ticks.y.left = element_line(color = "black"),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank())
答案 0 :(得分:3)
我不确定这是否正是您想要的,但是尝试一下。
library(tidyverse)
ggplot(mpg, aes(cty, hwy)) +
geom_point() +
geom_segment(aes(x = min(cty), y = 25,
xend = max(cty), yend = 25),
data = mpg) +
theme_minimal() +
theme(axis.line.y = element_line(color = "black"),
axis.ticks.y.left = element_line(color = "black"),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank())