[R] Combining a greek letter and a newline on the same label

David Winsemius dwinsemius at comcast.net
Thu Aug 25 17:59:30 CEST 2011


On Aug 25, 2011, at 11:23 AM, Sébastien Vigneau wrote:

> Hi,
>
> I would like to add a two-lines label consisting of:
> "Delta word1\n
> word2"
> (with Delta being the actual greek letter).

But you are not saying how word1 and word2 are supposed to be  
positioned relative to each other and to Delta.

>
> However, when I try "expression(paste(Delta,"word1\nword2"))", I  
> obtain the
> following display:
> "word1\n
> Delta word2".
>
> Do you have any idea on how to obtain the desired display?

\n does not get interpreted in plotmath expressions [as the  
help(plotmath) page states explicitly], but as your example shows [to  
my complete surprise] if you have then inside text they will get  
interpreted . Take a look at atop() and over().

Perhaps:

plot(1,1,main=expression(over(Delta~word1, word2)))

If you don't mean the ratio of change in word1 per word2, then this  
also gives another possible answer to your vague question.

expression(atop(Delta~word1, word2))

and yet a third:

plot(1,1,main=expression(Delta~over(word1, word2)))

By the way the paste is entirely unneeded there. Using * and ~ as  
connectors helps keep these expression more readable. Comma then  
separate arguments for "important" plotmath functions.

-- 

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list