[英]Increase distance between axis line and plot lines on ggplot
How do I increase the distance between the axis.line.y
below and the blue geom_hline
below? 如何增加下面的axis.line.y
和下面的蓝色geom_hline
之间的距离? I want a gap between the two, I don't want them kissing as shown on the plot. 我想要两者之间的差距,我不希望他们如情节所示亲吻。
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())
I'm not sure if this is exactly what you want but try it. 我不确定这是不是你想要的但是试试看。
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())
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.