

   text {base}                                  R Documentation

   AAdddd TTeexxtt ttoo aa PPlloott

   DDeessccrriippttiioonn::

        `text' draws the strings given in the vector `labels'
        at the coordinates given by `x' and `y'.  `y' may be
        missing since `xy.coords(x,y)' is used for construction
        of the coordinates.

   UUssaaggee::

        text (x, ...)
        text.default (x, y = NULL, labels = seq(along = x), adj = NULL,
                      pos = NULL, offset = 0.5, ...)

   AArrgguummeennttss::

       x, y: numeric vectors of coordinates where the text
             `labels' should be written.  If the length of `x'
             and `y' differs, the shorter one is recycled.

     labels: character or expression with the text to be writ-
             ten.

        adj: one or two values in [0,1] which specify the x
             (and optionally y) adjustment of the labels.

        pos: a position specifier for the text.  If specified
             this overrides any `adj' value given.  Values of
             `1', `2', `3' and `4', respectively indicate posi-
             tions below, to the left of, above and to the
             right of the specified coordinates.

     offset: when `pos' is specified, this value gives the off-
             set of the label from the specified coordinate in
             fractions of a character width.

        ...: further graphical parameters (from `par'), such as
             `cex', etc.

   DDeettaaiillss::

        `labels' must be of type `character' or `expression'.
        In the latter case, quite a bit of mathematical nota-
        tion is available such as sub- and superscripts, greek
        letters, fractions, etc.

        `adj' allows adjustment of the text with respect to
        `(x,y)'.  Values of 0, 0.5, and 1 specify left/bottom,
        middle and right/top, respectively.  The default is for
        centered text, i.e., `adj = c(0.5, 0.5)'. Accurate ver-
        tical centering needs character metric information on
        individual characters, which is only available on some
        devices.

        The `pos' and `offset' arguments can be used in con-
        junction with values returned by `identify' to recreate
        an interactively labelled plot.

        Text can be rotated by using graphical parameters `srt'
        (see `par'); this rotates about the centre set by
        `adj'.

   SSeeee AAllssoo::

        `mtext', `title'; `plotmath' for details and more exam-
        ples on mathematical annotation.

   EExxaammpplleess::

        plot(-1:1,-1:1, type = "n", xlab = "Re", ylab = "Im")
        K <- 16; text(exp(1i * 2 * pi * (1:K) / K), col = 2)

        ## The following two examples use latin1 characters: these may not
        ## appear correctly (or be omitted entirely).
        plot(1:10, 1:10, main = "text(..) examples\n~~~~~~~~~~~~~~",
             sub = "R is GNU (C), but not (R) ..")
        mtext("<<ISO-accents>>: +- 'e`e /o/O oa<oA ae<AE", side=3)
        points(c(6,2), c(2,1), pch = 3, cex = 4, col = "red")
        text(6, 2, "the text is CENTERED around (x,y) = (6,2) by default",
             cex = .8)
        text(2, 1, "or Left/Bottom - JUSTIFIED at (2,1) by `adj = c(0,0)'",
             adj = c(0,0))
        text(4, 9, expression(hat(beta) == (X^t * X)^{-1} * X^t * y))
        text(4, 8.4, "expression(hat(beta) == (X^t * X)^{-1} * X^t * y)", cex = .75)
        text(4, 7, expression(bar(x) == sum(frac(x[i], n), i==1, n)))

        ## Two more latin1 examples
        text(5,10.2,"Le fran,cais, c'est fa,cile: R`egles, Libert'e, Egalit'e, Fraternit'e..")
        text(5,9.8, "Jetz no chli z"urit"u"utsch: (noch ein biBchen Z"urcher deutsch)")

