Suppose there are two curves f1[x]
and f2[x]
, and we want to fill the area between them using colors corresponding to the vaule of f2[x]-f1[x]
, so that any filling line segemts with the same length will be rendered with same color. My question is, how can we do this using built-in commands like Filling
, FillingStyle
and ColorFunction
, etc? A direct call of ColorFunction
will not help because in specification
ColorFunction -> Function[{x, y}, g[x,y]]
the x
and y
are refered always as the absoulate coordinates, however we need to refer to y2-y1
in our case. I have not figured out how to get this done using pure function.
I can write a code doing this from sketch similiar to the idea suggested in this question, but such treatment is not universal... Besides, there is already such an example documented in Mathematica,
ListLinePlot[Accumulate[RandomReal[{-1, 1}, 250]], ColorFunction -> "Rainbow", Filling -> Axis]
which is actually a similar case to my question but with f1[x]
always equal to zero. So I think there should be a solution using only built-in commands...
Furthermore, if there is indeed such a solution, then we can simply generalize the relation from merely f2[x]-f1[x]
to more interesting forms.