rotate X axis labels 45 degrees on grouped bar plot R

前端 未结 3 655
心在旅途
心在旅途 2020-12-17 22:43

How can I rotate the X axis labels 45 degrees on a grouped bar plot in R?

I have tried the solution suggested here but got something very messy, the labels seem to h

3条回答
  •  无人及你
    2020-12-17 22:52

    Try the first answer:

    x <- barplot(table(mtcars$cyl), xaxt="n")
    labs <- paste(names(table(mtcars$cyl)), "cylinders")
    text(cex=1, x=x-.25, y=-1.25, labs, xpd=TRUE, srt=45)
    

    But change cex=1 to cex=.8 or .6 in the text() function:

    text(cex=.6, x=x-.25, y=-1.25, labs, xpd=TRUE, srt=45)
    

    In the picture you posted, it appears to me that the labels are just too big. cex sets the size of these labels.

提交回复
热议问题