I wanted to stagger my x-axis labels in ggplot2
. Amazingly, the thing I tried worked (thanks to @Hadley and the consistent grammar!).
c <- ggplot(mtcars, aes(factor(cyl)))
c <- c + geom_bar()
c + theme(axis.text.x = element_text(vjust = c(0, 0.1, 0.2)))
But it seems that as a consequence, the amount of vertical space dedicated to the margin became unnecessarily large. Any tips on getting this back down to size?
Not entirely sure what's going on, but here is a potential work-around:
c + theme(axis.text.x = element_text(vjust = grid::unit(c(-2, 0, 2), "points")))
For some reason the default units of npc
which are fractions of the containing element size are not working right when you use a greater than one length vjust
vector. I also suspect vjust
was not fully intended to work with longer than one vectors (not sure).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With