2

In this adaptation of an ancient post ( Placing a ContourPlot under a Plot3D ) I would like to know how to coordinate the colors of the surface on the color of the scheme LightTerrain or any other scheme. In other words, I wonder how to know which colors are used in a scheme.

 f = E^-(x^2 + y^2);

 min = 0;
 max = 1;
  f1 = Plot3D[f, {x, -2, 2}, {y, -2, 2}, PlotRange -> {min, max}, 
  ClippingStyle -> None, MeshFunctions -> {#3 &}, Mesh -> 15, 
  MeshStyle -> Opacity[.5], 
  MeshShading -> {{Opacity[.3], Blue}, {Opacity[.8], LightBlue}}, 
  Lighting -> "Neutral", Boxed -> False];
  slice = SliceContourPlot3D[f, 
  z == min - 2, {x, -2, 2}, {y, -2, 2}, {z, min - 2, min + 1}, 
  PlotRange -> {min, max}, Contours -> 15, Axes -> False, 
  PlotPoints -> 50, PlotRangePadding -> 0, 
  ColorFunction -> "LightTerrain"];
 Show[f1, slice, PlotRange -> All, BoxRatios -> {1, 1, 1}, 
  FaceGrids -> {Back, Left}]

enter image description here

Valeriy
  • 185
  • 10
cyrille.piatecki
  • 4,582
  • 13
  • 26

2 Answers2

3

"I wonder how to know which colors are used in a scheme"

The blending colors for gradient color schemes can be obtained using the function DataPaclets`ColorData`GetBlendArgument. For example:

DataPaclets`ColorData`GetBlendArgument["LightTerrain"]

enter image description here

For continuous gradient schemes (all except "BrightBands" and "DarkBands") blending argument is just a list of colors. For a randomly selected 12 of continuous gradient schemes, the color lists are:

Grid[{#, Grid[{{"blend arguments: ", Row @ DataPaclets`ColorData`GetBlendArgument @ #}, 
 {"image: ",  ColorData[#, "Image"]}}, Alignment -> {{Left, Left}, Center}]} & /@ 
  RandomSample[Delete[ColorData["Gradients"], {{10}, {16}}], 12], 
 Dividers -> All, Alignment -> {{Left, Left}, Center}]

enter image description here

For the two discontinuous schemes:

Grid[{#, Grid[{{"blend arguments: ", Row @ DataPaclets`ColorData`GetBlendArgument @ #}, 
  {"image: ", ColorData[#, "Image"]}}, Alignment -> {{Left, Left}, Center}]} & /@ 
  ColorData["Gradients"][[{10, 16}]], 
 Dividers -> All, Alignment -> {{Left, Left}, Center}]

enter image description here

kglr
  • 394,356
  • 18
  • 477
  • 896
2

Give this a look:

AssociationMap[Blend["LightTerrain", #1] &, Range[0, 1, .05]]

This is the simplest way to get the actual colors and here's why:

ColorData returns a ColorDataFunction which is really a special InterpolatingFunction-esque object.

In this case we get:

In[622]:= ColorData["LightTerrain"] // InputForm

Out[622]//InputForm=
ColorDataFunction["LightTerrain", "Gradients", {0, 1}, Blend["LightTerrain", #1] & ]

Then look at ColorDataFunction // SubValues to see what this does and it's really only Blend["LightTerrain", #1] & that's important here.

But the gradients defining "LightTerrain" in blend aren't obviously scrapeable. They're probably possible to find, but it's likely not worth it when you can just use the function.

b3m2a1
  • 46,870
  • 3
  • 92
  • 239