[R] Line spacing in graphics

Sarah Goslee sarah.goslee at gmail.com
Sat Feb 19 00:55:44 CET 2011


Peter,

Try par()$lheight

The catch is, you need to set it *before* the call to text()

par(lheight=.8) # closer together
text(x, y, "whatever\nsecondline")

The best place to find options like lheight is in ?par

Sarah

On Fri, Feb 18, 2011 at 6:41 PM, Peter Langfelder
<peter.langfelder at gmail.com> wrote:
> Hi all,
>
> tried to google but found nothing, so here goes the question: is there
> a way to control line spacing when displaying text in graphical mode
> (for example, using text())?
>
> As an example, run the following code:
>
> plot(c(0,1), c(0,1), type = "n", axes = FALSE, xlab = "", ylab = "")
> text(0.5, 0.5, "Line 1\nLine 2", cex = 3)
>
> Is there a way to control the line spacing between the text lines
> "Line 1" and "Line 2" in the resulting plot?
>
> Thanks!
>
> Peter
>


-- 
Sarah Goslee
http://www.functionaldiversity.org



More information about the R-help mailing list