I have combined multiple plots using the ggarrange
function. Now, I want the title to be bold, as it is now, but not the subtitle.
This is my code:
plotCNAE_decils <- ggarrange(plotalimentacio_2021_decils, plottabac_2021_decils, plotvestit_2021_decils, plothabitatge_2021_decils, plotmobles_2021_decils, plotsalut_2021_decils,
plottransport_2021_decils, plotcomunicacions_2021_decils, plotoci_2021_decils, ploteducacio_2021_decils, plotrestaurants_2021_decils, plotaltres_2021_decils,
ncol=4, nrow=3, common.legend=TRUE, legend="bottom")
plotCNAE_decils
annotate_figure(plotCNAE_decils,
top=text_grob("Despesa monetària en els diferents grups CNAE, per decils de renda. Espanya (2021) \nEn euros i percentatge", size=15, face="bold", hjust=0, x=0.01, vjust=0.4),
bottom=text_grob("Font: Elaboració pròpia a partir de dades de l'Enquesta de pressupostos familiars del 2021, base 2016, de l'INE.", hjust=0, x=1, face="italic", size=10))
CodePudding user response:
This could be done in patchwork
using ggplot2 title and subtitle fields.
library(ggplot2); library(patchwork)
p1 <- ggplot(mtcars, aes(wt, mpg)) geom_point()
p2 <- ggplot(mtcars, aes(gear, cyl)) geom_jitter()
p1 p2 plot_annotation(title = "Terrific title", subtitle = "Superlative subtitle")
I suspect there's a way to do what you want within ggarrange using gridtext::richtext_grob
but I haven't figured out all the syntax yet.)