[R] Multiline subtitle

Andre Luiz Tietbohl Ramos @ndre|tr@mo@ @end|ng |rom gm@||@com
Sat Jul 18 17:05:07 CEST 2026


Hello,

Suppose I want to have a multiline subtitle using ggplot() with aligned
strings between first line and second line like a table.  I'm using the
approach below to no avail,

tickers.subtitle <- c("CPFE3.SA",  "CXSE3.SA", " ALUP11.SA",  "BBAS3.SA",  "
CMIG4.SA",  "VALE3.SA", " LEVE3.SA", "VIVT3.SA", "TAEE4.SA", "RANI3.SA", "
BRSR6.SA", "SAPR4.SA")
ticker.subtitle.weights <- c("20.0%",   "15.0%",  "15.0%",  "5.0%", "5.0%",
"5.7%", "5.7%", "5.7%", "5.7%", "5.7%", "5.7%", "5.7%")

port_cumulative_ret %>% ggplot(aes(x = date, y = cum_ret)) +
...
labs(
...
subtitle = paste('Ativos: ', tickers.subtitle,
                          '\nPesos: ', ticker.subtitle.weights)
)

Any suggestions?

TIA,

--
André Luiz Tietbohl Ramos, PhD

	[[alternative HTML version deleted]]



More information about the R-help mailing list