Thanks to Ivan Krylov, David Winsemius and Duncan Murdoch for their
informative replies to my cri de coeur.  The most complete answer was
however provided off-list by Andrew Simmons who wrote a new and
carefully structured function plotASCII() to replace my old no-longer
functioning plot_ascii() function.

In the belief that others on the list might well be interested in seeing
Andrew's very elegant solution to my problem, I have attached (with
Andrew's permission) the code for plotASCII() (in the file
"plotASCII.txt").

Note that Andrew, very cautiously, uses syntax such as
"graphics::text(<whatever>) rather than just text(<whatever>).
I guess it never hurts to be cautious.

cheers,

Rolf Turner

-- 
Honorary Research Fellow
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276
plotASCII <- function (extended = TRUE, cex = graphics::par("cex"),
                       family = graphics::par("family"), plot = TRUE) {
    xlim <- c(0, 16)
    xvals <- 0:15
    if (extended) {
        codes <- 1:255
        ylim <- c(16, 0)
        yvals <- 0:15
    }
    else {
        codes <- 1:127
        ylim <- c(8, 0)
        yvals <- 0:7
    }
    ASCII <- as.character(str2expression(sprintf("\"\\x%02X\"", codes)))
    Encoding(ASCII) <- "latin1"
    ASCII <- enc2utf8(ASCII)
    names(ASCII) <- sprintf("%02X", codes)
    if (plot) {
        opar <- graphics::par(cex = cex, family = family,
                              mar = c(0, 2.1, 2.1, 0))
        on.exit(graphics::par(opar))
        graphics::plot(
            xlim = xlim - 0.5, ylim = ylim - 0.5,
            x = NA_real_, y = NA_real_,
            axes = FALSE, ann = FALSE
        )
        graphics::text(
            x = rep(xvals, 16), y = rep(yvals, each = 16),
            labels = c(NA, ASCII)
        )
        graphics::axis(side = 3L, at = xvals, labels = sprintf("%X", xvals), 
las = 1)
        graphics::axis(side = 2L, at = yvals, labels = sprintf("%X", yvals), 
las = 1)
        invisible(ASCII)
    }
    else ASCII
}
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Reply via email to