Skip to content
Prev 387219 / 398502 Next

New line in caption with math symbols embedded in expression (paste(

This is beautiful. Thanks!
G

-----Original Message-----
From: Rui Barradas <ruipbarradas at sapo.pt> 
Sent: Thursday, February 18, 2021 2:10 PM
To: Izmirlian, Grant (NIH/NCI) [E] <izmirlig at mail.nih.gov>; r-help at r-project.org
Subject: Re: [R] New line in caption with math symbols embedded in expression (paste(

Hello,

First of all the plotmath in your code doesn't need paste, expression alone will do it.

I am not sure that the following is what you want. I create the caption beforehand, in order to make the plotting code simpler.
The asterisks/tildes make less/more space between the text line's elements.


e <- expression(
   atop(
     P * "(" * FDP ~ ">" ~ alpha * ") " ~
       "for 'FDR' and 'Auto' FDP control method, vs '" *
       m * "' at levels of 'eff size' (col) and '" *
       p[1] * "' (row)" ~ "and",
     "a new line" ~
       bar(x) == sum(frac(x[i], n), i==1, n)
   )
)

p <- ggplot(data=DAT, aes(x=X)) + geom_point(aes(y=Y)) + 
geom_line(aes(y=Y.p))
p <- p + labs(caption = e)
p <- p + theme(plot.caption = element_text(hjust = 0))
p


Hope this helps,

Rui Barradas
?s 17:37 de 18/02/21, Izmirlian, Grant (NIH/NCI) [E] via R-help escreveu: