We consider a table of the form
data = Flatten[Table[{i,j,f[i,j]},{i,1,ni},{j,1,nj}],1]
The function f[i_,j_] has been made so that 0 ≤ f[i,j] ≤ 1. I can plot this map using
ListDensityPlot[data, ColorFunction -> "Rainbow", InterpolationOrder -> 0]
However, the colors attributed to the values of f[i,j] are continuous and vary smoothly. I would like to have only a finite number of colors. For example : 0 ≤ f[i,j] ≤ 1/2 --> Red and 1/2 ≤ f[i,j] ≤ 1 --> Blue (Of course, my real bins will be different, but this is the idea.)
How could I proceed to make this plot so that only a finite number of colors are present on the plot with custom ranges ? I guess it has something to do with the ColorFunction, but I can't get the syntax correct...

ColorFunction -> (If[# < .5, Red, Blue] &), ColorFunctionScaling -> False. However, I still don't understand this syntax. I would prefer to define a functionfcolor[value_]which would give me the color associated to a valuef[i_,j_]. What would then be the syntax forColorFunction -> ...? – jibe May 13 '14 at 08:15ColorFunction -> fcolor– Sjoerd C. de Vries May 13 '14 at 09:30