Re: [R-SIG-Finance] Multiline subtitle
Peter Langfelder <[email protected]> Sat, 18 Jul 2026 23:55:14 +0800
| Newsgroups | gmane.comp.lang.r.general |
|---|---|
| Message-ID | <CA+hbrhUPBek6XtkaOQXn87C97zd1Nr=xxLsS-gs=FHqU2TG_LA@mail.gmail.com> |
On Sat, Jul 18, 2026 at 11:25=E2=80=AFPM Dirk Eddelbuettel <[email protected]>= wrote: > > > Posting to two lists at once is considered rude. Please don't do it. I > removed r-sig-finance for this reply as there is nothing finance-specific > here. > > When I want subtitles in a ggplot I rely on the existing features, for > example arguments 'label' and 'subtitle' to sub-function ggttitle(). That > said I do not think vertical alignment is offered by default by a theme. I unfortunately cannot comment on ggplot directly, but if I were asked to do the same using standard R plotting, I would use legend instead of subtitle. The legend function has argument ncol which allows you to specify number of columns as well as position and justification. A simple example with a "subtitle" centered below the actual plot could go like this: par(mar =3D c(5, 3.1, 2, 1)); par(mgp =3D c(2, 0.7, 0)); plot(1:10, xlab =3D "", ylab =3D "x") box =3D par("usr"); legend((box[1]+box[2])/2, box[3] - 2.5*strheight("M"), legend =3D c(matrix(c("A", "B", "C", "1", "2", "3"), 2, 3, byrow =3D TRU= E)), pch =3D 1, col =3D rep(0, 6), ncol =3D 3, xpd =3D TRUE, bty =3D "n", xju= st =3D 0.5); I would be surprised if ggplot's legend functionality did not have a similar level of flexibility. Or, if you don't insist on using ggplot, you could adapt the code above. Anyway, hope this helps at least a little. Peter