[R] ggplot's subtitle with table

Andre Luiz Tietbohl Ramos @ndre|tr@mo@ @end|ng |rom gm@||@com
Tue Jun 9 15:53:44 CEST 2026


Hello,

Is there a way to put a custom 2 rows table with its columns alignment as a
subtitle in ggplot? As an example I'm using the code below but it is not
aligned as I want,

tickers.clean <- paste(str_replace_all(tickers,'.SA$', ''))
tickers.subtitle  <- paste(tickers.clean, sep = ' ', collapse = '    ')
ticker.subtitle.weights  <- paste(percent(wts, accuracy = 0.1), sep = ' ',
collapse = '    ')

ggplot(aes(x = date, y = cum_ret)) +
labs(x = 'Date',
        y = 'Cummulative Return',
         title = paste0('Portfolio Return ', length(tickers.clean), ' on ',
                        limite_data_final,
                        ' since ',
                        limite_data_inicial),
         subtitle = paste('Ativos: ', tickers.subtitle,
                          '\nPesos: ', ticker.subtitle.weights)
         )
)

TIA,

--
André Luiz Tietbohl Ramos, PhD

	[[alternative HTML version deleted]]



More information about the R-help mailing list