下面是一些代码,改编自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)
}
你可以编辑你的问题来指定'filled.contour'的不良副作用是什么吗?从'filled.contour'减去可能比添加到'image'更容易。 – joran
目前,我最大的问题是,我想通过'轮廓添加从不同的数据集轮廓()'的情节。随着'filled.contour()',轮廓将需要调整,以考虑对剧情的侧面默认斜键。 – brews