0

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

GreenlawM
  • 55
  • 1
  • 11
  • 1
    If I understand you correctly you are looking for a solution like this? https://stackoverflow.com/a/47464897/4739420 – Christopher Stephan Dec 19 '17 at 17:42
  • @ChristopherStephan this wasn't exactly what I was looking for, but close. I did get something working, but I would like to figure out how to do it with a large scale of 75 breaks like I had. I had to bring the number of breaks down to 15 to make it work with that example. Thanks for sending. – GreenlawM Dec 19 '17 at 20:53
  • 3
    It would be useful to provide some example data that can be used to answer your question, and code that focuses on the specific issue at hand. There is little point in showing code operating on data we do not have. See examples in rasterVis and this: https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5965451#5965451 – Robert Hijmans Dec 21 '17 at 03:33

0 Answers0