I'm trying to get the x-axis labels ("Text 1" through "Text 6") to move inwards. I want "Text 1" to be aligned to the right, so that this label does not start before x = 0. Similarly, I want "Text 6" to be aligned to the left, so that this label ends before x = 6 (right now it's not even fully visible).
d=data.frame(x=c(1,2,3,4,4,6), y=c(3,7,1,4,5,6))
lbl <- paste("Text",seq(1,6,1))
ggplot() + geom_point(data=d, mapping=aes(x=x, y=y)) +
scale_x_continuous(expand=c(0,0),labels=lbl,breaks=seq(1,6,1))
Any suggestions?
Not sure how "hacky" this is, but one way would be to specify the
hjust
: