简体   繁体   中英

Adjust rotated axis labels to ticks

I have rotated my ggplot - geom_bar axis labels 90 degrees, and now want the labels to be aligned with the ticks. is this possible as seen below they are slightly slanted to the right of the tick?

在此处输入图片说明

Adjust text position with vjust option (theme in p2 is what you need).

library(ggplot2)

p1 <- qplot(rownames(head(mtcars)), 1) +
    ggtitle("vjust = 0") +
    theme(axis.text.x = element_text(angle = 90, vjust = 0))
p2 <- qplot(rownames(head(mtcars)), 1) +
    ggtitle("vjust =  0.3") +
    theme(axis.text.x = element_text(angle = 90, vjust = 0.3))

gridExtra::grid.arrange(p1, p2, ncol = 2)

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM