4

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}*")"))
Jilber Urbina
  • 58,147
  • 10
  • 114
  • 138
user3170629
  • 489
  • 3
  • 12
  • 21

1 Answers1

12

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

Sven Hohenstein
  • 80,497
  • 17
  • 145
  • 168
  • 6
    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' – user3170629 Jan 11 '14 at 19:54
  • @user3170629 Why don't you use `\n` if you're not happy with `atop`? – Sven Hohenstein Jan 11 '14 at 19:57
  • 2
    \n causes large breaks in the middle of the text due to the expression function – user3170629 Jan 11 '14 at 20:14