Hi,
You can do this by adding two more segments that represent the top and bottom horizontal line, make sure they start / end outside the area you want to crop, them crop the plot by limiting the x-axis
library(ggplot2)
#Data points
myData = data.frame(
x = 1:5,
xend = 2:6,
y = 1:5,
yend = 1:5
)
#Horizontal lines
ends = data.frame(
x = c(0,6),
xend = c(1,7),
y = c(0,6),
yend = c(0,6)
)
#Plot
ggplot(myData) +
geom_segment(aes(x=x, y=y, xend=xend, yend=yend)) +
geom_segment(data = ends, aes(x=x, y=y, xend=xend, yend=yend), color = "red") +
coord_cartesian(xlim=c(0.8,6.2))

Created on 2021-11-22 by the reprex package (v2.0.1)
Of note: you have to use the coord_cartesian() function to set the limit, because if you would just use the xlim() function it would remove the red lines since they are not fully displayed