I try to use Manipulate
to specify my interactive own colors and scaling for the ColorFunction
in ListContourPlot
. In the forum I found this very useful code
Manipulate[{a, x, y, z, b} =
Rescale[{aa, xx, yy, zz, bb}, MinMax@{aa, xx, yy, zz, bb}];
colors =
Transpose[{{a, x, y, z, b}, {Blue, Lighter@LightBlue, White, Yellow,
Red}}];
DensityPlot[
Sin[x] Cos[y], {x, -2 \[Pi], 2 \[Pi]}, {y, -2 \[Pi], 2 \[Pi]},
ColorFunction -> (Blend[colors, #] &), PlotLegends -> Automatic,
PlotPoints -> 100], {{aa, 0, "Blue"}, 0,
1, .01}, {{xx, 0.25, "Lighter@LightBlue"}, 0,
1, .01}, {{yy, .5, "White"}, 0, 1, .01}, {{zz, .75, "Yellow"}, 0,
1, .01}, {{bb, 1, "Red"}, 0, 1, .01}]
Dynamic[colors]
How can I adapt it for my ColorFunction and my data instead of Sin[x] Cos[y]
myTemperatureMap[f_] :=
Blend[{{-1, Blue}, {-0.25, Lighter@LightBlue}, {-0.25, White}, {0,
White}, {0.3, Yellow}, {0.6, Red}}, f];
data = Import[file, "Table", HeaderLines -> 2];
dataT = Transpose[data];
dataT = {dataT[[1]]*10, dataT[[2]]*10, dataT[[3]]};
dataT[[3]] = Rescale[dataT[[3]], MinMax[dataT[[3]]], {-1., 1.}];
ListContourPlot[data,
PlotRange -> {{-0.05, 0.05}, {-0.05, 0.05}, {-1., 1.}},
ColorFunction -> myTemperatureMap, ColorFunctionScaling -> False,
ContourStyle -> None, Contours -> 200,
PlotLegends ->
BarLegend[{myTemperatureMap[#] &, {-1, 1}},
LegendMarkerSize -> 300,
LabelingFunction -> (Style[NumberForm[#, {Infinity, 2}], Bold,
Black, 12] &)]];
I tried this but doesn't work the color doesn't change...
Manipulate[{a, x, y, z, b} = Rescale[{aa, xx, yy, zz, bb}, MinMax@{aa, xx, yy, zz, bb}];
colors = Transpose[{{a, x, y, z, b}, {Blue, Lighter@LightBlue, White,
Yellow, Red}}];
ListContourPlot[data,
ColorFunction -> myTemperatureMap, ColorFunctionScaling -> False,
ContourStyle -> None, Contours -> 200,
PlotLegends ->
BarLegend[{myTemperatureMap[#] &, {-1, 1}},
LegendMarkerSize -> 300,
LabelingFunction -> (Style[NumberForm[#, {Infinity, 2}], Bold,
Black, 12] &)]], {{aa, 0, "Blue"}, -1, 1, .01}, {{xx, 0.25, "Lighter@LightBlue"}, -1, 1, .01}, {{yy, .5, "White"}, -1, 1, .01}, {{zz, .75, "Yellow"}, -1, 1, .01}, {{bb, 1, "Red"}, -1, 1, .01}]
Dynamic[colors]
-1
,, e.g.{{bb, 1, "Red"}, -1, 1, .01}
and put yourListContourPlot
in place ofDensityPlot
inManipulate[...]
? $\endgroup$