I'm still new to plotting in Mathematica and have been trying to figure out how to overlay a single color (white) over a color gradient (in this case rainbow) to highlight a range of values in a plot I generated with a mathematical function. I though this would be relatively straightforward since it appeared similar to several other questions asked here (especially this one: Impose the color for one discrete value above a color predefined gradient), but the methodology that the person presented did not solve my problem. This is the original ArrayPlot with the rainbow gradient
I want to highlight a range (say 2-3) with white and if I apply the method used in the linked post by defining a custom colorfunction like
cf = If[(2 <= # <= 3), White, Blend["Rainbow", #]] &;
and then apply it to the same array
ArrayPlot[a, PlotLegends -> Automatic, ClippingStyle -> Automatic, ColorFunction -> cf, AspectRatio -> 2, ColorFunctionScaling -> False]
Then I get the following image
The area I want is highlighted but it doesn't fit in nicely in the rainbow colorfunction as desired and as it seemed to for the previous question. If I do not use the ColorFunctionScaling->False option I get no change to the plot at all. I will note that I tried the other method in that post as well defining a piecewise function and got similar results. I also tried using ColorRule and it worked okay for one value (say 2=white), but I tried several methods for feeding it a range of values and that yield similar results to the second image.
Any insight would be appreciated