Here's how to drive Brett's and belisarius's point home. Let's modify your original code a bit so we can see exactly what things are passed to your ColorFunction
:
Reap[ListLinePlot[{2, 4, 6, 8, 10, 12},
ColorFunction -> Function[{x, y}, Sow[x]; If[x <= 3, Blue, Red]]]]
We obtain your erroneous plot as the first component of a list, and the list of all the values passed to your ColorFunction
: {{0., 0.2, 0.4, 0.6, 0.8, 1.}}
as the second component. Effectively, what was done is to apply Rescale[]
to the original list you plotted (i.e. Rescale[N@{2, 4, 6, 8, 10, 12}]
). That's because ColorFunctionScaling
is by default set to True
:
Options[ListLinePlot, ColorFunctionScaling]
{ColorFunctionScaling -> True}
Let's see what happens if we disable ColorFunctionScaling
:
ListLinePlot[{2, 4, 6, 8, 10, 12},
ColorFunction -> Function[{x, y}, If[x <= 3, Blue, Red]],
ColorFunctionScaling -> False]
Note the nice purplish shade in between 3 and 4, showing that the color interpolation is working nicely.
ColorFunctionScaling
$\endgroup$ColorFunctionScaling
? My specific color function deliversBlue
orRed
– two well defined color directives. $\endgroup$