Mark Heckmann
2011-Sep-08 17:20 UTC
[R] problem with math expressions in grid graphics when using line breaks (\n)
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
Dennis Murphy
2011-Sep-08 21:30 UTC
[R] problem with math expressions in grid graphics when using line breaks (\n)
>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. >
Apparently Analagous Threads
- using regular expressions to retrieve a digit-digit-dot structure from a string
- no partial matching of argument names after dots argument - why?
- Reordering the results from table(cut()) by break argument
- blank space escape sequence in R?
- RGtk2 / gWidgets - addHandlerClicked Problem