[R-sig-Geo] editing a correlogram

Ben Tupper btupper @end|ng |rom b|ge|ow@org
Sat Mar 16 22:02:19 CET 2019


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


> spdep::plot.spcor
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>



> On Mar 16, 2019, at 1:16 PM, Leonardo Matheus Servino <leonardomservino using gmail.com> wrote:
> 
> I tried the function par() and arguments inside the plot(), but some
> parameters doesn't change.
> For example, the argument pch=, which changes the symbols that represents
> the points in the plot doesn't work.
> 
> 
> Em sáb, 16 de mar de 2019 às 13:48, Sarah Goslee <sarah.goslee using gmail.com <mailto:sarah.goslee using gmail.com>>
> escreveu:
> 
>> Of course.
>> 
>> The ... argument to the plot method means that you can use standard
>> base graphics options to customize as you wish.
>> 
>> ?par gives the whole list, although they may not all be useful for
>> correlograms.
>> 
>> If you have specific questions after you try customizing to your
>> liking, the list can certainly help with details.
>> 
>> Sarah
>> 
>> On Sat, Mar 16, 2019 at 11:00 AM Leonardo Matheus Servino
>> <leonardomservino using gmail.com> wrote:
>>> 
>>> Hello,
>>> 
>>> I've been tried to use the function "sp.correlogram". After plot the
>>> correlogram, I would like to edit the grafic's appearence, to publish it.
>>> It is possible?
>>> 
>>> Thanks
>>> 
>>> --
>>> Leonardo Matheus Servino
>>> Pós-Graduação em Evolução e Diversidade
>>> Universidade Federal do ABC - UFABC - Centro de Ciências Naturais e
>> Humanas
>>> 
>> 
>> --
>> Sarah Goslee (she/her)
>> http://www.numberwright.com
>> 
> 
> 
> -- 
> Leonardo Matheus Servino
> Pós-Graduação em Evolução e Diversidade
> Universidade Federal do ABC - UFABC - Centro de Ciências Naturais e Humanas
> 
> LED I - Laboratório de Evolução e Diversidade I - Bloco Delta, sala 202
> 
> Rua Arcturus, 3. Jardim Antares
> 09606-070 São Bernardo do Campo - SP
> 
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo using r-project.org <mailto:R-sig-Geo using r-project.org>
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo <https://stat.ethz.ch/mailman/listinfo/r-sig-geo>
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/






	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list