[R] problem with math expressions in grid graphics when using line breaks (\n)

Dennis Murphy djmuser at gmail.com
Thu Sep 8 23:30:53 CEST 2011


>From the plotmath help page:

"Control characters (e.g. \n) are not interpreted in character strings
in plotmath, unlike normal plotting."

In other words, "you can't do that".

However, since you're using grid graphics, this thread from the
ggplot2 group might be helpful:
http://groups.google.com/group/ggplot2/browse_thread/thread/7ff9a9675e197ff3/cdc31fb3a5d7688d?lnk=gst&q=Baptiste%2Bmultiple%2Bline%2Blabel#cdc31fb3a5d7688d

The code by Baptiste Auguie is what to look for.

HTH,
Dennis

On Thu, Sep 8, 2011 at 10:20 AM, Mark Heckmann <mark.heckmann at gmx.de> wrote:
> I want to plot a multiline annotation including a mathematical expression using grid graphics (grid.text).
> This works fine for a single line, but the math expression is misplaced when I insert a line break ("\n" escape sequence):
>
> grid.text(expression(paste("Some words here\n more ", sigma)))
>
> Does someone have an idea how to fix that?
> TIA!
>
> Mark
> –––––––––––––––––––––––––––––––––––––––
> Mark Heckmann
> Blog: www.markheckmann.de
> R-Blog: http://ryouready.wordpress.com
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list