Skip to content

How can I brake a label in two lines when using expression()?

2 messages · Beatriz De Francisco, David Winsemius

#
On May 7, 2012, at 6:20 AM, Beatriz De Francisco wrote:

            
My first idea would be that you should learn to post "minimal"  
examples. Since your question is about how to use plotmath  
expressions, you could skip all the data of that with::

xyplot(1~1) # as the "scaffold".

Your question had nothing to do with that data, and it required that  
the responder locate the package that had panel.errbars() which you  
rather carelessly failed to mention. You can keep those second line  
items together using group() but the arrangement on the page is  
unsatisfactory since the text newline does not do a linefeed :

ylab=expression("Mean Reapisration Rate
  "*group("(", umol.*L^-1*.g *"(AFDM)"^-1,")"))


Try using atop():

ylab=expression(atop("Mean Reapisration Rate",
                      "("*mu*mol~L^-1*.g~"("*AFDM*")"^-1*")")
                       )

So this code is my nomination for a minimal solution:

xyplot(1~1, ylab=expression(atop("Mean Reapisration Rate",
                      "("*mu*mol %.% L^-1 %.% g~"("*AFDM*")"^-1*")")
                       ) )

I also took the liberty of changing the "umol" to a proper micro-mol  
with the use of the Greek mu. I also put in proper "cdots" instead of  
periods. (So now it meets my personal standards for labeling  
proprieties.) If you don't use atop(), the registration of the "bottom  
expression" gets messed up, at least in my attempts. One of the known  
difficulties with plotmath expressions is the difficulty in getting a  
proper line break. atop() solves the two line problem but not the  
three line problem.