Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 3.0.x中的填充轮廓抛出错误_R_Plot_Contour - Fatal编程技术网

R 3.0.x中的填充轮廓抛出错误

R 3.0.x中的填充轮廓抛出错误,r,plot,contour,R,Plot,Contour,我有一个用于绘制填充轮廓的自定义函数,它主要基于Carey McGilliard和Bridget Ferris的工作()和 filled.contour3函数在R2.15.3中运行良好,但在R3.0.x中抛出错误 Error in .Internal(filledcontour(as.double(x), as.double(y), z, as.double(levels), : there is no .Internal function 'filledcontour' 您能帮我找到

我有一个用于绘制填充轮廓的自定义函数,它主要基于Carey McGilliard和Bridget Ferris的工作()和

filled.contour3
函数在R2.15.3中运行良好,但在R3.0.x中抛出错误

Error in .Internal(filledcontour(as.double(x), as.double(y), z, as.double(levels),  : 
  there is no .Internal function 'filledcontour'
您能帮我找到一个解决方案或解决方法吗?这样我就可以使用R3.0.x中的
filled.contour3()
函数了*我的很多工作都依赖于这个函数,而且我使用的是LInux,所以在生产机器上更改R版本并不是那么容易。将乐意提供赏金。*

若要重现错误,请首先提供以下信息

filled.contour3 <-
    function (x = seq(0, 1, length.out = nrow(z)),
                        y = seq(0, 1, length.out = ncol(z)), z, xlim = range(x, finite = TRUE), 
                        ylim = range(y, finite = TRUE), zlim = range(z, finite = TRUE), 
                        levels = pretty(zlim, nlevels), nlevels = 20, color.palette = cm.colors, 
                        col = color.palette(length(levels) - 1), plot.title, plot.axes, 
                        key.title, key.axes, asp = NA, xaxs = "i", yaxs = "i", las = 1, 
                        axes = TRUE, frame.plot = axes,mar, ...) 
    {
        # modification by Ian Taylor of the filled.contour function
        # to remove the key and facilitate overplotting with contour()
        # further modified by Carey McGilliard and Bridget Ferris
        # to allow multiple plots on one page

        if (missing(z)) {
            if (!missing(x)) {
                if (is.list(x)) {
                    z <- x$z
                    y <- x$y
                    x <- x$x
                }
                else {
                    z <- x
                    x <- seq.int(0, 1, length.out = nrow(z))
                }
            }
            else stop("no 'z' matrix specified")
        }
        else if (is.list(x)) {
            y <- x$y
            x <- x$x
        }
        if (any(diff(x) <= 0) || any(diff(y) <= 0)) 
            stop("increasing 'x' and 'y' values expected")
        # mar.orig <- (par.orig <- par(c("mar", "las", "mfrow")))$mar
        # on.exit(par(par.orig))
        # w <- (3 + mar.orig[2]) * par("csi") * 2.54
        # par(las = las)
        # mar <- mar.orig
        plot.new()
        # par(mar=mar)
        plot.window(xlim, ylim, "", xaxs = xaxs, yaxs = yaxs, asp = asp)
        if (!is.matrix(z) || nrow(z) <= 1 || ncol(z) <= 1) 
            stop("no proper 'z' matrix specified")
        if (!is.double(z)) 
            storage.mode(z) <- "double"
        .Internal(filledcontour(as.double(x), as.double(y), z, as.double(levels), 
                                                        col = col))
        if (missing(plot.axes)) {
            if (axes) {
                title(main = "", xlab = "", ylab = "")
                Axis(x, side = 1)
                Axis(y, side = 2)
            }
        }
        else plot.axes
        if (frame.plot) 
            box()
        if (missing(plot.title)) 
            title(...)
        else plot.title
        invisible()
    }


filled.legend <-
    function (x = seq(0, 1, length.out = nrow(z)), y = seq(0, 1, 
                                                                                                                 length.out = ncol(z)), z, xlim = range(x, finite = TRUE), 
                        ylim = range(y, finite = TRUE), zlim = range(z, finite = TRUE), 
                        levels = pretty(zlim, nlevels), nlevels = 20, color.palette = cm.colors, 
                        col = color.palette(length(levels) - 1), plot.title, plot.axes, 
                        key.title, key.axes, asp = NA, xaxs = "i", yaxs = "i", las = 1, 
                        axes = TRUE, frame.plot = axes, ...) 
    {
        # modification of filled.contour by Carey McGilliard and Bridget Ferris
        # designed to just plot the legend
        if (missing(z)) {
            if (!missing(x)) {
                if (is.list(x)) {
                    z <- x$z
                    y <- x$y
                    x <- x$x
                }
                else {
                    z <- x
                    x <- seq.int(0, 1, length.out = nrow(z))
                }
            }
            else stop("no 'z' matrix specified")
        }
        else if (is.list(x)) {
            y <- x$y
            x <- x$x
        }
        if (any(diff(x) <= 0) || any(diff(y) <= 0)) 
            stop("increasing 'x' and 'y' values expected")
        #  mar.orig <- (par.orig <- par(c("mar", "las", "mfrow")))$mar
        #  on.exit(par(par.orig))
        #  w <- (3 + mar.orig[2L]) * par("csi") * 2.54
        #layout(matrix(c(2, 1), ncol = 2L), widths = c(1, lcm(w)))
        #  par(las = las)
        #  mar <- mar.orig
        #  mar[4L] <- mar[2L]
        #  mar[2L] <- 1
        #  par(mar = mar)
        # plot.new()
        plot.window(xlim = c(0, 1), ylim = range(levels), xaxs = "i", 
                                yaxs = "i")
        rect(0, levels[-length(levels)], 1, levels[-1L], col = col)
        if (missing(key.axes)) {
            if (axes) 
                axis(4)
        }
        else key.axes
        box()
    }
#
#    if (!missing(key.title)) 
#        key.title
#    mar <- mar.orig
#    mar[4L] <- 1
#    par(mar = mar)
#    plot.new()
#    plot.window(xlim, ylim, "", xaxs = xaxs, yaxs = yaxs, asp = asp)
#    if (!is.matrix(z) || nrow(z) <= 1L || ncol(z) <= 1L) 
#        stop("no proper 'z' matrix specified")
#    if (!is.double(z)) 
#        storage.mode(z) <- "double"
#    .Internal(filledcontour(as.double(x), as.double(y), z, as.double(levels), 
#        col = col))
#    if (missing(plot.axes)) {
#        if (axes) {
#            title(main = "", xlab = "", ylab = "")
#            Axis(x, side = 1)
#            Axis(y, side = 2)
#        }
#    }
#    else plot.axes
#    if (frame.plot) 
#        box()
#    if (missing(plot.title)) 
#        title(...)
#    else plot.title
#    invisible()
#}

filled.touro3如果使用非标准API,则会发生这种情况。您可以这样做,但不能期望它得到维护

改变

.Internal(filledcontour(as.double(x), as.double(y), z, as.double(levels), 
                                                        col = col))

这一变化是通过以下方式宣布的:

基础图形的C代码已迁移到图形 包(因此不再使用.Internal()调用)


你听说过(强调“最小”)吗

非常感谢。我使用了非标准API,因为R的base filled.contour函数具有复杂的filled.contour图(添加文本、图例等)。我想知道R3.0.x中的这种变化是否有记录在案?就像这个答案中强调的“最小”。这个问题本来很容易解决。
.Internal(filledcontour(as.double(x), as.double(y), z, as.double(levels), 
                                                        col = col))
.filled.contour(as.double(x), as.double(y), z, as.double(levels), 
                            col = col)