How to display all x labels in R barplot?

前端 未结 3 1681
有刺的猬
有刺的猬 2020-11-29 02:11

This is a basic question but I am unable to find an answer. I am generating about 9 barplots within one panel and each barplot has about 12 bars. I am providing all the 12 l

3条回答
  •  北海茫月
    2020-11-29 03:00

    You may be able get all of the labels to appear if you use las=2 inside the plot() call. Otherwise, you will need to use xaxt="n" and then put the labels in with a separate call to axis(1, at= ..., labels=...).

    Another method is to first collect the midpoints and then use text() with xpd and srt to control the degree of text rotation:

    text(x=midpts, y=-2, names(DD), cex=0.8, srt=45, xpd=TRUE)
    

    The y-value needs to be chosen using the coordinates in the plotted area.

提交回复
热议问题