【问题标题】:Font size of labels and values in a ggarranged plotggarranged 图中标签和值的字体大小
【发布时间】:2020-12-13 21:38:56
【问题描述】:

我在 ggplot 中制作了 4 个条形图:o、p、q、r。 我使用 ggpubr 包和以下代码将它们放在一个图中:

library(ggpubr)

figure = ggarrange(o + font("y.text", size = 5), p + 
font("y.text", size = 5), q + font("y.text", size = 5), r + 
font("y.text", size = 5), labels = c("Total", "DF", "SE", "RU"), ncol = 2, nrow = 2)

annotate_figure(figure,top = text_grob("Distribución de víctimas por departamento según hecho victimizante", 
color = "black", face = "bold", size = 10))

这是结果:

我的问题:条形图两端的标签和值太大。关于如何使它们更小的任何想法(我不想触摸每个图 o、p、q、r 的代码)?提前谢谢你。

【问题讨论】:

    标签: r ggplot2 label bar-chart ggpubr


    【解决方案1】:

    有人给了我这个答案,我觉得可以接受:

    lista<-list(o=o,p=p,q=q,r=r)
    lista_limpia<-map(lista,function(x){ a<-ggplot_build(x); a$data[[2]]$size<-2;b<-as_ggplot(ggplot_gtable(a));b})
    
    figure<-ggarrange(lista_limpia$o,lista_limpia$p,lista_limpia$q,lista_limpia$r,
                      labels = c("Total", "DF", "SE", "RU"), ncol = 2, nrow = 2,
                      font.label=list(color="black",size=9))
    annotate_figure(figure,top = text_grob("Distribución de víctimas por departamento según hecho victimizante", 
                       color = "black", face = "bold", size = 10))
    

    结果:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-12-23
      • 2021-07-08
      • 1970-01-01
      • 1970-01-01
      • 2015-09-07
      • 2016-03-14
      相关资源
      最近更新 更多