im trying to use ggarrange from ggpubr to have multiple, plots in one general plot. I have my plots saved, and each one has a title, i want to eliminate those titles from each plot when the multiple plot comes, here are my plots:
dic_plot_int <- ordenes_dic %>%
filter(corteesp == 1) %>%
group_by(espesor) %>%
summarise(MTS.4 = sum(MTS.4)) %>%
ggplot(aes(espesor,MTS.4, fill= espesor))+
geom_col(width = .5)+ geom_bar(stat= "identity", colour ="black")+
geom_text(aes(label = MTS.4), vjust = -0.2) +
labs(title = "Indicador de Productividad de órdenes Integrales", subtitle = "Fenabel Aldama Diciembre 2023", x= "Espesor del Cristal en milímetros", y= "Metros Cuadrados", fill="Espesor")+
theme(plot.title = element_text(hjust=0.5), plot.subtitle = element_text(hjust = 0.5))+
scale_fill_manual(values = c("#21BCDF","#74EA2C","#EA441B","#D051F5"), labels =c("6mm","8mm","9.5mm", "12.7mm"))+
theme(panel.background = element_rect(fill = '#F7D2AF', color = 'purple'))+
coord_cartesian(ylim = c(0,400))
jan_plot_int <- ordenes_ene %>%
filter(corteesp == 1) %>%
group_by(espesor) %>%
summarise(MTS.4 = sum(MTS.4)) %>%
ggplot(aes(espesor,MTS.4, fill= espesor))+
geom_col(width = .5)+ geom_bar(stat= "identity", colour ="black")+
geom_text(aes(label = MTS.4), vjust = -0.2) +
labs(title = "Indicador de Productividad de órdenes Integrales", subtitle = "Fenabel Aldama Enero 2024", x= "Espesor del Cristal en milímetros", y= "Metros Cuadrados", fill="Espesor")+
theme(plot.title = element_text(hjust=0.5), plot.subtitle = element_text(hjust = 0.5))+
scale_fill_manual(values = c("#21BCDF","#EA441B","#D051F5"), labels =c("6mm","9.5mm", "12.7mm"))+
theme(panel.background = element_rect(fill = '#F7D2AF', color = 'purple'))+
coord_cartesian(ylim = c(0,400))
I dont want to eliminate from each plot the title beacuse there are some parts on my markdown where I show each plot separately, but when i want to show both plots i want to eliminate the tiles and only have one main title.
I tried using this:
plot <- ggarrange(dic_plot_int,jan_plot_int,ncol = 2,nrow = 1,common.legend = TRUE, legend = "right")
annotate_figure(plot, top = text_grob("Indicador de Productividad órdenes Integrales", face = "bold", size = 14))
But it looks really squeeze with the titles from each plot, is there any way to eliminate the titles from those plots only for the multiple plot? or somehow have something like the common.legend thing but for the title? enter image description here
One option would be to put your plots in a
list, then use e.g.lapplyto remove the titles before passing the list of plots toggarrangevia theplotlist=argument.Using a minimal reproducible example based on
mtcarslet's first reproduce your issue:Now, using
lapplyandlabs()we can remove the titles before passing thelistof plots toggarrange:Or as already suggested by @r2evans in his comment using
patchworkyou could do: