title: levelplot: how to adjust scale levels (at) & scale labels (labels)
body: <p>I have raster-objects with either categorical values (-1,0,1) or some values with skewed distributions that I want to plot with levelplot. I want to have different colors for negative values than for positive ones and white color for values around 0. I want the scale to show only few discrete steps as I want the spacing non-equi-distant and the ranges are sometimes very narrow. I use</p>
  <blockquote>
  <p>colorkey=list(at=c(), labels=c())</p>
  </blockquote>
  <p>to pass the arguments to levelplot. This works for the scale but the colorcoding of the actual values is not equal to what the scale displays. If I use the argument</p>
  <blockquote>
  <p>at=c()</p>
  </blockquote>
  <p>solely, scale-values and values in the lattice are corresponding. If I add <code>labels=c()</code> also independently they will not display at the scale but only at contour-lines.
  So my question:</p>
  <p><strong>How can I label my scale, set 'at', and have the values in the lattice correspond to the values of my scale all at the same time?</strong> Here is some example data:</p>
  <pre><code>library(raster)
  library(colorspace)
  library(rasterVis)
  X &lt;- raster(nrow=10,ncol=10)
  set.seed(1)
  X[] &lt;- rchisq(df=10,n=10*10)*c(1,-1)
  X[X[]&gt;0] &lt;- X[X[]&gt;0]+seq(1,100,length.out=length(X[X[]&gt;0]))
  Uniques &lt;- cellStats(X,stat=unique)
  Uniques.max &lt;- max(Uniques)
  Uniques.min &lt;- min(Uniques)
  Acol.regions &lt;- colorspace::diverge_hsv(n=9)
  </code></pre>
  <p>If I use colorkey:</p>
  <pre><code>levelplot(X, col.regions = Acol.regions,colorkey=list(
    at=round(c(seq(Uniques.min,0,length.out=5)[-5],0,seq(0,Uniques.max,length.out=5)[-1]),2),
    labels=as.character(round(c(seq(Uniques.min,0,length.out=5)[-5],0,seq(0,Uniques.max,length.out=5)[-1]),2)*2)),
            margin=F)
  </code></pre>
  <p>I end up with the correct way of displaying the scale but the values in the lattice are wrongly colored:
  <img src="https://i.stack.imgur.com/Izkt9.png" alt="correct scale but wrong values in the lattice" /></p>
  <p>If I separately pass <code>at=c(), labels=c()</code> :</p>
  <pre><code>levelplot(X, col.regions = Acol.regions,
    at=round(c(seq(Uniques.min,0,length.out=5)[-5],0,seq(0,Uniques.max,length.out=5)[-1]),2),
    labels=as.character(round(c(seq(Uniques.min,0,length.out=5)[-5],0,seq(0,Uniques.max,length.out=5)[-1]),2)*2),
            margin=F)
  </code></pre>
  <p>I end up with corresponding values in the scale and lattice, but the labels are not displayed:
  <img src="https://i.stack.imgur.com/ywbrZ.png" alt="enter image description here" /></p>
  <p>Kind regards,
  Eric</p>