What do I have to do if I want to invert the color scale in "AvocadoColors"
, and add a condition that the zero value is denoted as white, whereas rest of values (> 0
) are shown accordingly to "AvocadoColors"
scheme?
2 Answers
ColorData[{"AvocadoColors", "Reversed"}][0]
RGBColor[1., 0.984375, 0.230411]
You can temporarily define this color as White
using Block
:
data = RandomReal[1, {50, 3}];
ldp1 = ListDensityPlot[data, ImageSize -> 300,
ColorFunction -> ColorData["AvocadoColors"]];
ldp2 = ListDensityPlot[data, ImageSize -> 300,
ColorFunction -> ColorData[{"AvocadoColors", "Reversed"}]];
ldp3 = Block[{RGBColor}, RGBColor[1., 0.984375, 0.230411] = White;
ListDensityPlot[data, ImageSize -> 300,
ColorFunction -> ColorData[{"AvocadoColors", "Reversed"}]]];
Row[{ldp1, ldp2, ldp3}]
A safer method than redefining a color would be to use Lighter[]
with a sharp exponential or Gaussian drop, e.g.
DensityPlot[Sin[x + Sin[y]], {x, 0, 6}, {y, 0, 6},
ColorFunction -> (Lighter[ColorData[{"AvocadoColors", "Reversed"}, #],
Exp[-#^2/(1*^-3)]] &)]