Rotating x axis labels in R for barplot

后端 未结 8 648
暖寄归人
暖寄归人 2020-11-27 12:29

I am trying to get the x axis labels to be rotated 45 degrees on a barplot with no luck. This is the code I have below:

barplot(((data1[,1] - average)/averag         


        
8条回答
  •  攒了一身酷
    2020-11-27 12:39

    EDITED ANSWER PER DAVID'S RESPONSE:

    Here's a kind of hackish way. I'm guessing there's an easier way. But you could suppress the bar labels and the plot text of the labels by saving the bar positions from barplot and do a little tweaking up and down. Here's an example with the mtcars data set:

    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)
    

提交回复
热议问题