Skip to content

lattice: ltext() does not accept NULL (PR#5290)

1 message · Deepayan Sarkar

#
On Monday 24 November 2003 05:42, wolfram@fischer-zim.ch wrote:
The following should fix this :


ltext <-
    function(x, y = NULL, labels = seq(along = x),
             col = add.text$col,
             cex = add.text$cex,
             srt = 0,
             font = 1,
             adj = c(.5, .5),
             pos = NULL,
             ...)
{
    add.text <- trellis.par.get("add.text")
    xy <- xy.coords(x, y)
    if (!is.null(pos))
        adj <-
            if (pos == 1) c(.5, 1)
            else if (pos == 2) c(1, .5)
            else if (pos == 3) c(.5, 0)
            else if (pos == 4) c(0, .5)
            else stop("Invalid value of pos")
    if (length(adj) == 1) adj <- c(adj, .5)
    grid.text(label = labels, x = xy$x, y = xy$y,
              gp = gpar(col = col, font = font,
              fontsize = cex * trellis.par.get("fontsize")$default),
              just = c(if (adj[1] == 0) "left"
              else if (adj[1] == 1) c("right")
              else "centre",
              if (adj[2] == 0) "bottom"
              else if (adj[2] == 1) c("top")
              else "centre"),
              rot = srt,
              default.units = "native")
}