问题
Title says it all, pretty much. So far as I can tell, trying to pass a simple color palette by using the col
argument, e.g., rasterImage(mydata,xleft=1,ybottom=1,xright=2,ytop=2,col=grey(0:4095/4096))
fails. What's more confusing is that the default palette seems to depend on the class of mydata
.
If I have a matrix, rasterImage(as.raster(mymatrix), {etc}
plots in grayscale, while using a RasterLayer
object, rasterImage(as.raster(myRaster),{etc}
plots in a topo color set.
Any suggestions for alternative (fast) tools to plot large images gratefully accepted.
回答1:
I think just using useRaster=TRUE
inside the basic graphics:image
function is fine.
This works, and very quickly (as opposed to not rasterizing a large matrix), with a matrix or a RasterLayer object:
image(mydata, useRaster=TRUE, col={whatever})
I should have tried that before going off into wrapper functions.
来源:https://stackoverflow.com/questions/18835412/can-color-palette-be-specified-for-rasterimage