Reputation: 169
I made 4 barplots in ggplot: o, p, q, r. I put them together in a single plot using the ggpubr package and the following code:
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))
My problem: the labels and the values at the extremes of the bars are too big. Any idea on how to make them smaller (I don't want to touch the code of each of the plots o, p, q, r)? Thank you in advance.
Upvotes: 5
Views: 12377
Reputation: 169
Someone gave me this answer, which I find acceptable:
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))
Upvotes: 5