r - Custom legend in fille.contour3 -


i trying use costume legend filled.contour3, in example:

colorramppalette(c('white','blue','green','yellow','red','darkmagenta','darkviolet'))(15) 

when use filled.contour3 predefined legend (e.g., terrain.colors) works fine. if try add costume legend (e.g., terrain.colors(10)) error message:

error in .filled.contour(as.double(x), as.double(y), z, as.double(levels),  :  not find function "color.palette" 

here sample code:

#generate fake data x = rep(c(10,11,12),length = 9) y = rep(c(1,2,3),each = 3) z = runif(n=9,min = 0,max = 1) xcoords = unique(x) ycoords = unique(y) surface.matrix = matrix(z,nrow=length(xcoords),ncol=length(ycoords),byrow=t)  #this works: filled.contour3(xcoords,ycoords,surface.matrix,color=terrain.colors,xlab = "",ylab = "",xlim = c(min(xcoords),max(xcoords)),ylim = c(min(ycoords),max(ycoords)),zlim = c(min(surface.matrix),max(surface.matrix)))  #this doesn't work: filled.contour3(xcoords,ycoords,surface.matrix,color=terrain.colors(10),xlab = "",ylab = "",xlim = c(min(xcoords),max(xcoords)),ylim = c(min(ycoords),max(ycoords)),zlim = c(min(surface.matrix),max(surface.matrix))) 

i use r 3.0.3 on win7 64 ,ilik

?filled.contour has 2 options set color:

color.palette: color palette function used assign colors in plot.

col: explicit set of colors used in plot. argument overrides palette function specification. there should 1 less color levels

you're supplying vector of colors color, interpreted color.palette. if want supply predefined vector of colors, use col instead:

cols = colorramppalette(c('white','blue','green','yellow','red','darkmagenta','darkviolet'))(15) filled.contour(xcoords,ycoords,surface.matrix,col=cols,xlab = "",ylab = "",xlim = c(min(xcoords),max(xcoords)),ylim = c(min(ycoords),max(ycoords)),zlim = c(min(surface.matrix),max(surface.matrix))) 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -