increase legend font size ggplot2

后端 未结 4 532
逝去的感伤
逝去的感伤 2020-12-12 15:20

Is there a way to increase the font size in ggplot2? I think I need to specify something like legend.key.width = unit(2, \"line\") in the the

相关标签:
4条回答
  • 2020-12-12 15:48

    You can use theme_get() to display the possible options for theme. You can control the legend font size using:

    + theme(legend.text=element_text(size=X))
    

    replacing X with the desired size.

    0 讨论(0)
  • 2020-12-12 15:51

    A simpler but equally effective option would be:

    + theme_bw(base_size=X)
    
    0 讨论(0)
  • 2020-12-12 16:03

    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, col=as.factor(cyl))) +
      geom_point() +
      theme_bw() +
      theme(legend.text=element_text(size=rel(0.5)))
    
    0 讨论(0)
  • 2020-12-12 16:04
    theme(plot.title = element_text(size = 12, face = "bold"),
        legend.title=element_text(size=10), 
        legend.text=element_text(size=9))
    
    0 讨论(0)
提交回复
热议问题