Changing font size and direction of axes text in ggplot2

前端 未结 7 1243
萌比男神i
萌比男神i 2020-11-28 17:37

I am plotting a graph with a categorical variable on the x axis and a numerical variable on the y axis.

For the x axis, given that there are many data points, the de

7条回答
  •  北海茫月
    2020-11-28 18:10

    Ditto @Drew Steen on the use of theme(). Here are common theme attributes for axis text and titles.

    ggplot(mtcars, aes(x = factor(cyl), y = mpg))+
      geom_point()+
      theme(axis.text.x = element_text(color = "grey20", size = 20, angle = 90, hjust = .5, vjust = .5, face = "plain"),
            axis.text.y = element_text(color = "grey20", size = 12, angle = 0, hjust = 1, vjust = 0, face = "plain"),  
            axis.title.x = element_text(color = "grey20", size = 12, angle = 0, hjust = .5, vjust = 0, face = "plain"),
            axis.title.y = element_text(color = "grey20", size = 12, angle = 90, hjust = .5, vjust = .5, face = "plain"))
    

提交回复
热议问题