col.persp3d <-
function(z, colfun, ncol=12, colcoe=1,
colrange=range(z, na.rm=T),...){
#ncol: The number of color you use if colcoe=1;
#colcoe: some sort of expanding factor. If you are using topo.colors, you may
#don't want to use the full range of topo colors. Using colcoe>1
#will enable some truncation at the lower spectrum of topo.colors.
#see the tail function below;
#colrange: The real range of the z value to which these colors are mapped
#it may be larger than the actual range of Z values, as you can expect.
# ncol=12
# colcoe=1
# z=p_norm_100_mat
# colrange=range(z, na.rm=T)
# colfun=brewer.pal
#require(RColorBrewer)
if(class(colfun)!="function")
stop("A color scheme function is needed for col.persp3d, such as
topo.colors, or brewer.pal")
ncolor <- ncol
funmatch <- match.fun(colfun)
pre_colors <- funmatch(trunc(colcoe* ncolor), ...)
couleurs <- tail(pre_colors,ncolor)
zlim <- colrange
nrz <- nrow(z)
ncz <- ncol(z)
col <- couleurs[trunc((z-zlim[1])
/(zlim[2]-zlim[1])*(ncol-1))+1]
return(col)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.