kalinoaj
(Anthony Kalinowski)
March 9, 2018, 7:04pm
1
Here is a command that generates a temp vs x and y.
It gives a nice 3 d contour with color shading, but no legend that says what. Value is assigned to each color.
Plot3D[ufun[x, y], {x, xlow, xhigh}, {y, ylow, yhigh}, ColorFunction -> "TemperatureMap"]
What to add to get the color legend?
mthiel
(Marco Thiel)
March 9, 2018, 10:32pm
2
Hi,
let me try to give a slightly more specific example:
ufun[x_, y_] := Cos[(x^2 + y^2)] Exp[-0.1 (x^2 + y^2)]
{xlow, xhigh} = {-6, 6};
{ylow, yhigh} = {-6, 6};
Plot3D[ufun[x, y], {x, xlow, xhigh}, {y, ylow, yhigh}, ColorFunction -> "TemperatureMap", PlotPoints -> 50, PlotRange -> All, PlotLegends -> Automatic]
Is that what you are looking for? That is, of course, not a ContourPlot. A ContourPlot would look like this:
ContourPlot[ufun[x, y], {x, xlow, xhigh}, {y, ylow, yhigh}, ColorFunction -> "TemperatureMap", PlotRange -> All, Contours -> 50, PlotLegends -> Automatic, ContourStyle -> None]
Cheers,
Marco
kalinoaj
(Anthony Kalinowski)
March 10, 2018, 12:00am
3
Thanks for the answer!!
I would like to force the high and low color cutoffs of the function being plotted so that when I compare two similar plots, red, blue …etc means the same numerical value in both plots.
How would you do that?
Thanks in advance
mthiel
(Marco Thiel)
March 10, 2018, 1:14am
4
Hi,
this is not particularly good, but I think it might work. I generate a list of frames and animate them so that it becomes clear that the colour bar is the same as the values of the function change:
ufun[x_, y_] := Cos[(x^2 + y^2)] Exp[-0.1 (x^2 + y^2)]
{xlow, xhigh} = {-6, 6};
{ylow, yhigh} = {-6, 6};
Monitor[frames =
Table[GraphicsRow[{Plot3D[a ufun[x, y], {x, xlow, xhigh}, {y, ylow, yhigh}, ColorFunction -> (ColorData["TemperatureMap"][Rescale[#3, {-1.5, 1.5}]] &), ColorFunctionScaling -> False, PlotPoints -> 40, PlotRange -> {All, All, {-2, 2}}],
BarLegend[{"TemperatureMap", {-1.5, 1.5}}]}, ImageSize -> Large,Alignment -> {{Center, Left}}], {a, 1, 1.5, 0.02}];, a]
This can be done easier, but the code gives you quite some control about nearly all parts of the image.
Cheers,
Marco