R levelplot adjust colour scale

1.7k views Asked by At

I am trying to adjust my colour scale on a level plot using the rasterVis package. My code plots a raster. I am using manually set colour scale that classifies that data into 5 quantiles. I would like to have the labels stay at the values I have set, but instead of a linear scale as it appears now, have equal space between the labels. Is this possible with levelplot??

cor = M[, c("lon", "lat")]
sPDF <- SpatialPointsDataFrame (cor, data=M)
proj4string(sPDF)<-(p$geog.proj)

#Create Rasters
grid.sum <- rasterize(x=sPDF, y=grid, field=v, fun=grid.fun)

#Define colour scale
z <- getValues(grid.sum)
z <- z[is.finite(z)]
z <- round(z, digits=0)

quant <- unique(quantile(z, seq(0,1, length.out=75)))
quant.small <- unique(quantile(z, seq(0,1, length.out=5)))
ckey <- list(at=quant, labels=list(at=quant.small))


print(
  levelplot(grid.sum, at=quant, colorkey=ckey, col.regions=p$seis, 
    alpha.regions=1, margin=F, xlab="", ylab="", main=name, 
    scales = list(x=list(cex=0.7), y=list(cex=0.7)))
    + layer(sp.polygons(coast, fill='lightgrey', alpha = 0.2))
    + layer(sp.lines(contours, col='dimgrey', alpha=0.6, lwd= 0.4)))

enter image description here

0

There are 0 answers