Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/73.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'中的颜色渐变创建图例、关键帧或颜色渐变;s图像()_R_Plot - Fatal编程技术网

为R'中的颜色渐变创建图例、关键帧或颜色渐变;s图像()

为R'中的颜色渐变创建图例、关键帧或颜色渐变;s图像(),r,plot,R,Plot,在R会话中,给定: foo <- matrix(1:25, 5, 5) image(foo) foo以下是一些从zernike软件包改编的代码。您可以全部使用,也可以只拉出创建渐变关键点的部分。 #CGWitthoft于2011年4月13日撰写。从 #zernike软件包的所有者 pupilplot <- function (wf, cp = NULL, col = topo.colors(256), addContours = FALSE, cscale = TRUE, ..

在R会话中,给定:

foo <- matrix(1:25, 5, 5)
image(foo)

foo以下是一些从zernike软件包改编的代码。您可以全部使用,也可以只拉出创建渐变关键点的部分。
#CGWitthoft于2011年4月13日撰写。从
#zernike软件包的所有者

 pupilplot <- function (wf, cp = NULL, col = topo.colors(256), addContours = FALSE, 
cscale = TRUE, ...) 
 {
     if (cscale) {
         mar.orig <- (par.orig <- par(c("mar", "las", "mfrow")))$mar
        on.exit(par(par.orig))
        w <- (3 + mar.orig[2]) * par("csi") * 2.54
        layout(matrix(c(2, 1), ncol = 2), widths = c(1, lcm(w)))
        par(las = 1)
        mar <- mar.orig
        mar[4] <- mar[2]
        mar[2] <- 1
        par(mar = mar) 
    thelist <- list(...)  
    findz <- which(names(thelist) == 'zlim')  
    if (length(findz) > 0 ) {   
        zlim <- thelist$zlim  
        }else{  
                zlim <- range(wf, finite = TRUE) #the original line  
        } 
 # end of my hack  
        levels <- seq(zlim[1], zlim[2], length = length(col))
        plot.new()
        plot.window(xlim = c(0, 1), ylim = range(levels), xaxs = "i", yaxs = "i")
        rect(0, levels[-length(levels)], 1, levels[-1], col = col,  density = NA)
        axis(4)
         box()
        mar <- mar.orig
        mar[4] <- 0
        par(mar = mar)
    }
    if (is.null(cp)) {
        axis1 <- 1:nrow(wf)
        axis2 <- 1:ncol(wf)
    }
    else {
         axis1 <- ((1:nrow(wf)) - cp$xc)/cp$rx
        axis2 <- ((1:ncol(wf)) - cp$yc)/cp$ry
    }
    image(axis1, axis2, wf, col = col, asp = 1, xlab = "X", ylab = "Y",  ...)
     if (addContours) 
        contour(axis1, axis2, wf, add = TRUE)
}

pupilclot您能否编辑您的问题,以明确说明
填充轮廓的不良副作用是什么?从
填充的轮廓中减去轮廓可能比添加到
图像中更容易。目前,我最大的问题是,我试图通过
轮廓()
将不同数据集中的轮廓添加到绘图中。使用
filled.contour()
,需要调整等高线以考虑绘图一侧的默认渐变关键点。