How to rotate the axis labels in ggplot2?

前端 未结 2 1300
礼貌的吻别
礼貌的吻别 2020-12-16 20:26

I have the following graph that I generated using ggplot2 \"enter

I had finalPlo

2条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-16 20:49

    For the rotation angle of the axis text you need to use element_text(). See this post on SO for some examples. For spacing over two lines I would add a "\n" on the location in the string where you want to put the newline.

    This will set the correct orientation for the y axis text and force a line break:

    finalPlot + ylab("Number of\nSolutions") + 
        theme(axis.title.y = element_text(angle = 0))
    

提交回复
热议问题