Skip to content
Prev 27134 / 29559 Next

editing a correlogram

Hi,

In this case the spdep::plot.spcor() function, which I think you are using, doesn't provide the mechanism for the caller to override the default pch value.  You can see this by looking at the pl.spcor function (as shown way below.)  I think it may be easiest for you to simply rewrite the function with the plotting parameters assigned as arguments.

Cheers,
Ben
function (x, main, ylab, ylim, ...) 
{
    if (missing(main)) 
        main <- x$var
    if ((x$method == "I") || (x$method == "C")) {
        lags <- as.integer(rownames(x$res))
        to.plot <- which((x$res[, 3] > 0) & (x$res[, 3] != Inf))
        sd2 <- rep(0, nrow(x$res))
        sd2[to.plot] <- 2 * sqrt(x$res[to.plot, 3])
        if (missing(ylim)) {
            ylim <- range(c(x$res[, 1] + sd2, x$res[, 1] - sd2))
        }
        if (missing(ylab)) 
            if (x$method == "I") 
                ylab <- "Moran's  I"
        if (x$method == "C") 
            ylab <- "Geary's  C"
        plot(lags, x$res[, 1], type = "p", pch = 18, ylim = ylim, 
            main = main, ylab = ylab, xaxt = "n")
        arrows(lags, x$res[, 1] + sd2, lags, x$res[, 1] - sd2, 
            length = 0.1, angle = 90)
        arrows(lags, x$res[, 1] - sd2, lags, x$res[, 1] + sd2, 
            length = 0.1, angle = 90)
        axis(1, at = lags)
        abline(h = x$res[1, 2])
    }
    else {
        res <- as.vector(x$res)
        lags <- as.integer(names(x$res))
        if (missing(ylim)) 
            ylim <- c(-1, 1)
        if (missing(ylab)) 
            ylab <- "Spatial autocorrelation"
        plot(lags, res, type = "h", ylim = ylim, main = main, 
            ylab = ylab, lwd = 4, xaxt = "n")
        axis(1, at = lags)
        abline(h = 0)
    }
}
<bytecode: 0x7fb8799d0e40>
<environment: namespace:spdep>
Ben Tupper
Bigelow Laboratory for Ocean Sciences
60 Bigelow Drive, P.O. Box 380
East Boothbay, Maine 04544
http://www.bigelow.org

Ecological Forecasting: https://eco.bigelow.org/