Changing font size and direction of axes text in ggplot2

前端 未结 7 1238
萌比男神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:29

    Adding to previous solutions, you can also specify the font size relative to the base_size included in themes such as theme_bw() (where base_size is 11) using the rel() function.

    For example:

    ggplot(mtcars, aes(disp, mpg)) +
      geom_point() +
      theme_bw() +
      theme(axis.text.x=element_text(size=rel(0.5), angle=90))
    

提交回复
热议问题