Include text control characters in plotmath expressions Include text control characters in plotmath expressions r r

Include text control characters in plotmath expressions


As you have figured plotmath does not support newlines within, but you can use mtext with bquote, to write each line. For example I create a list of lines :

Lines <- list(bquote(paste( "Plot of " , phi , " of: "  , .(lab))),              bquote(paste("Functional form: " , .(form)))mtext(do.call(expression, Lines),side=3,line=1:0)

enter image description here


For the sake of completeness, here's another solution using unicode and no expressions (adapted from here and here):

plot(x, y, type="b")title(main=paste("Plot of \u03A6 of:", lab, "\nFunctional form:", form), adj=0)

enter image description here


if you use grid graphics, then the following grob can be useful to space the lines according to their height,

library(devtools)source_gist(2732693)grid.expr(as.expression(Lines))

(using agstudy's Lines)