ggplot's subtitle with table
Andre Luiz Tietbohl Ramos <[email protected]> Tue, 9 Jun 2026 10:53:44 -0300
| Newsgroups | gmane.comp.lang.r.general |
|---|---|
| Message-ID | <CAPZA_qLuxkOnt4Kxef-oCv2u0+1gGBV=2J_FUdKeJLqEs+N=0w@mail.gmail.com> |
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 =3D ' ', collapse =3D ' ')
ticker.subtitle.weights <- paste(percent(wts, accuracy =3D 0.1), sep =3D '=
',
collapse =3D ' ')
ggplot(aes(x =3D date, y =3D cum_ret)) +
labs(x =3D 'Date',
y =3D 'Cummulative Return',
title =3D paste0('Portfolio Return ', length(tickers.clean), ' on =
',
limite_data_final,
' since ',
limite_data_inicial),
subtitle =3D paste('Ativos: ', tickers.subtitle,
'\nPesos: ', ticker.subtitle.weights)
)
)
TIA,
--
Andr=C3=A9 Luiz Tietbohl Ramos, PhD
[[alternative HTML version deleted]]