# Apply ColorData scheme for Plot from green to red

I'd like to apply a ColorData to this plot:

\[ScriptCapitalM] =
MixtureDistribution[{0.55, 0.35,
0.1}, {DiscreteUniformDistribution[{0, 0}],
NormalDistribution[0.25, .05],
DiscreteUniformDistribution[{1, 1}]}];

Plot[{CDF[\[ScriptCapitalM]]@x}, {x, -.001, 1.001}, Filling -> Axis,
PlotRange -> All, PlotStyle -> {{Blue, Thick}},
Frame -> {{True, False}, {True, False}},
FrameLabel -> {Style["Costs", Bold, 40],
Style["CDF(Costs)", Bold, 40]},
FrameStyle -> Directive[Thick, Black, 30], GridLines -> Automatic,
GridLinesStyle -> Directive[Gray, Dashed],
ColorFunction -> (ColorData["HTML", "MidnightBlue"])]


that starts from green (left) to red (right). I've checked the available schemes but apparently none matches my objective. Any ideas how to this? Thanks!

-

You can define the ColorFunction to be a function of the values in the plot. If you allow this to be an RGBColor function you can let it take in the value of the x coordinate and define the colour scheme as you need:

\[ScriptCapitalM] =
MixtureDistribution[{0.55, 0.35,
0.1}, {DiscreteUniformDistribution[{0, 0}],
NormalDistribution[0.25, .05],
DiscreteUniformDistribution[{1, 1}]}];

Plot[{CDF[\[ScriptCapitalM]]@x}, {x, -.001, 1.001}, Filling -> Axis,
PlotRange -> All, PlotStyle -> {{Blue, Thick}},
Frame -> {{True, False}, {True, False}},
FrameLabel -> {Style["Costs", Bold, 40],
Style["CDF(Costs)", Bold, 40]},
FrameStyle -> Directive[Thick, Black, 30], GridLines -> Automatic,
GridLinesStyle -> Directive[Gray, Dashed],
ColorFunction -> (Function[{x}, RGBColor[x, (1 - x), 0]])]


-
I'd like the red to dominate. I used: ColorFunction -> (Function[{x}, RGBColor[x, 0.25*(1 - x), 0]]) but this makes the colors really dark. Can you please tell me how to make them more clear? Thanks –  jpcgandre May 30 '13 at 1:54
The fourth slot in RGBColor allows you to specify the Opacity, this may help to lighten it a little. You can also user the Lighter function around the RGBColor function –  Jonathan Shock May 30 '13 at 2:00
You could also use: RGBColor[x, (1 - Sqrt[x]), 0] or some other power of x. –  Jonathan Shock May 30 '13 at 2:02
Just a final question: If I wanted to catch all the intermediate colors, i.e orange, yellow, etc... How can I do it? –  jpcgandre May 30 '13 at 2:18
The it's probably easiest to use ColorFunction -> (Function[{x}, Hue[x]]) or some function within the Hue command. –  Jonathan Shock May 30 '13 at 2:32