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 2

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}]

enter image description here


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)]] &)]

avocado with white


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.