2

I used Matlab jet color by applying the steps in this link as follows.

     Plot3D[Abs[E^(I (t/2 + x)) (Coth[t + x])], {x, -2, 2}, {t, -2, 2}, 
   ColorFunction -> #, PlotPoints -> 15, PlotRange -> All] & /@ {Hue, 
  JetCM}

enter image description here

  1. The JET color scheme didn't change with respect to the z-axis as HUE scheme in the left? I think that it will be a problem when I add a color bar.
  2. How to rescale the colors of HUE? (The red color is very dominant for this figure)
RF_1
  • 672
  • 2
  • 7

1 Answers1

1

The answer to part one of your question is that you must explicitly pass in the x, y, or z component to the ColorFunctionas shown below:

Plot3D[Abs[E^(I (t/2 + x)) (Coth[t + x])], {x, -2, 2}, {t, -2, 2}, 
   ColorFunction -> Function[{x, y, z}, #[z]], 
   PlotLegends -> Automatic, PlotPoints -> 15, 
   PlotRange -> All] & /@ {Hue, JetCM}

Plots without legends

As you can see, PlotLegends->Automatic fails to produce a legend. Presumably, it only works for named Color Schemes.

Since PlotLegends->Automatic fails, the answer to part two of your question is to create custom bar legends. One possible approach is shown below:

(*Read in the numerical data*)
Get["https://pastebin.com/raw/gN4wGqxe"]
plt = Plot3D[
   Abs[E^(I (t/2 + x)) (Coth[t + x])], {x, -2, 2}, {t, -2, 2}, 
   PlotPoints -> 15, PlotRange -> All];
pts = Join @@ Cases[Normal@plt, Line[x1__] :> x1, Infinity];
HueBL = BarLegend[{Hue, MinMax[pts]}, LegendFunction -> "Frame"];
JetCM = With[{colorlist = RGBColor @@@ jetColors}, 
   Blend[colorlist, #] &];
JetCMBL = 
  With[{colorlist = RGBColor @@@ jetColors}, 
   BarLegend[{((Blend[colorlist, Rescale[#, MinMax[pts]]] &)), 
     MinMax[pts]}, LegendFunction -> "Frame"]];
Legended[Plot3D[
    Abs[E^(I (t/2 + x)) (Coth[t + x])], {x, -2, 2}, {t, -2, 2}, 
    ColorFunction -> Function[{x, y, z}, #[[1]][z]], PlotPoints -> 15,
     PlotRange -> All], #[[2]]] & /@ {{Hue, HueBL}, {JetCM, JetCMBL}}

Custom bar legends

Tim Laska
  • 16,346
  • 1
  • 34
  • 58