If you inspect the InputForm
of the "ColorFunction"
property for "AvocadoColors"
you see that it uses Blend
with a list of colors:
ColorData["AvocadoColors", "ColorFunction"] // InputForm
ColorDataFunction["AvocadoColors", "Gradients", {0, 1}, Blend["AvocadoColors", #1] &]
Similarly, for "Rainbow"
and other gradient color schemes:
ColorData["Rainbow", "ColorFunction"] // InputForm
ColorDataFunction["Rainbow", "Gradients", {0, 1}, Blend["Rainbow", #1] & ]
The function DataPaclets`ColorData`GetBlendArgument
gives the list of colors used in Blend
:
clist = DataPaclets`ColorData`GetBlendArgument["AvocadoColors"]
Now you can replace the last color with White
and use with Blend
:
mycolorFunc = Blend[Append[Most[clist], White], #] &;
This function retains the yellow tones in the middle of the list. Alternatively, you can have White
play the role of Yellow
in your new color scheme using blends of the second color with White
to construct an alternative list of blending colors:
myclist = Prepend[FoldList[Blend[{#, White},#2]&, clist[[2]], {1, 2, 3}/3] , clist[[1]]]
mycolorFunc2 = Blend[myclist, #]&;
Examples:
Row[Plot3D[Sin[x y], {x, 0, 3}, {y, 0, 3}, ColorFunction -> #, ImageSize -> Medium]& /@
{"AvocadoColors", mycolorFunc[#3] &, mycolorFunc2[#3] &}]
Style[Row[LinearGradientImage/@{"AvocadoColors", mycolorFunc, mycolorFunc2},
Spacer[10]], ImageSizeMultipliers->{1,1}]
To add your custom color function to the existing color schemes you can use this answer by Mr. Wizard:
ColorData[1];
new = {{"myColorFunction", "", {}}, {"Gradients"}, 1, {0, 1}, myclist, ""};
AppendTo[DataPaclets`ColorDataDump`colorSchemes, new];
AppendTo[DataPaclets`ColorDataDump`colorSchemeNames, "myColorFunction"];
ColorData["myColorFunction"]
Examples:
BarLegend["myColorFunction", LegendLayout -> "Row", LegendMarkerSize -> {400, 100}]
PieChart[Range[10], ColorFunction -> "myColorFunction"]