Drop values near zero in contour fill plot for Makie

I’m trying to plot some data using a contour plot in Makie. My data has both negative and positive peaks. Near zero, there is a lot of noise. I want to highlight just the main peaks and valleys and I’d like anything near zero to be white. Makie’s contourf function has a :relative mode (see here) where you can drop either the high or low ranges, say the bottom 10%. I would like to drop the middle 10% or so, or somehow set the middle to be white so the peaks are easily identifiable.

I’ve tried creating two contour plots and overlapping them: one with the highest 95% (positive values) and one with the lowest 95% (the negative values). This actually gets very close to what I want, visually, but then each plot has its own Colorbar (blue gradient for positive and red for negative), which is not desirable.

Another option would be to apply a filter to the dataset and set very small values to zero, but I don’t really want to be manipulating the data.

Is there a way I haven’t thought of? Maybe there’s a way to set the levels that I’m not thinking of?

Here’s an example of roughly what I would like to achieve (this is not my data, but is similar, and I’m not sure how it was generated):

How about this:

data = [sin(x) * cos(y) for x in 0:0.1:4, y in 0:0.1:4] .+ 0.05 .* randn.()
zeroband_threshold = 0.2
threshold = maximum(abs, data)
nbands = 15
upperrange = range(zeroband_threshold, threshold, (nbands-1)÷2)
levels = [reverse(.-upperrange); upperrange]
f, ax, c = contourf(data, levels = levels, colormap = :RdBu)
contour!(ax, data, levels = levels, color = :black)
Colorbar(f[1, 2], c)


That looks really nice. Thank you for also including the black contour outlines. I didn’t think of that but it looks good.