Number line in ggplot – Posit Community

Hi. I want to draw a number line in ggplot. I don’t want all this height in the y axis, and I want the x axis numbers just below the points. How can I change my code? Thank you.

df <- data.frame(x = c(1,2,3,4,5,6,7,8,9,10),
y = c(0,0,0,0,0,0,0,0,0,0),
group = c(“A”,”A”,”A”,”B”,”A”,”A”,”A”,”A”,”A”,”A”))
ggplot(df, aes(x = x,y = y, group = group)) +
geom_point(aes(col = group, size=10)) +
scale_x_continuous(breaks=c(1,2,3,4,5,6,7,8,9,10)) +
scale_color_manual(values = c(“red”, “darkblue”)) +
theme_classic() +
theme(legend.position=”none”, axis.text.y=element_blank(), axis.ticks.y=element_blank() )

Read more here: Source link