How can you use the atop function in expression()?
Asked Answered
M

1

5

I need to add a line break but I am struggling with the atop function in expression(). The main is the part I would like to break into two lines.

> plot (DAC~Chlo,data=brazilw,
        pch=15,col="red",cex=0.5,
        main=expression("Fig. 3. Relationship
                        between diffuse attenuation coefficient at 490 nm 
                        (K"[d]*") and chlorophyll concentration at three coral
                         reef sites"),
        xlab=expression("Chlorophyll concentration (mg "*m^{-3}*")"),
        cex.lab=0.8,
        cex.main=0.8,
        cex.axis=0.8, 
        font.main=1,
        ylim=c(0,0.3),
        xlim=c(0,3.5), 
        ylab=expression("K"[d]*"(m"*-1^{-1}*")"))
Marcellamarcelle answered 11/1, 2014 at 19:40 Comment(0)
D
13

You did not specify, where you want to break the string, but this example should help you:

plot(1~1, 
 main=expression(atop("bla bla bla" ~ (K[d]),
                      "bla bla bla")))

enter image description here

Dogmatics answered 11/1, 2014 at 19:53 Comment(3)
Thank you for your help, that worked fine. But it seems that the atop function has caused more spacing comparing the line breaks in my other graphs that do not have the expression function and used \n instead. Is there a way to condence the title for 'atop'Marcellamarcelle
@Marcellamarcelle Why don't you use \n if you're not happy with atop?Dogmatics
\n causes large breaks in the middle of the text due to the expression functionMarcellamarcelle

© 2022 - 2024 — McMap. All rights reserved.