I produce a heat map with legend with the code shown below
Needs["PlotLegends`"]
mydata = Table[2 + Sin[x y/5.], {x, -10, 10}, {y, -10, 10}];
ShowLegend[
MatrixPlot[mydata,
Mesh -> True, ColorFunction -> "TemperatureMap",
FrameTicks -> None, MeshStyle -> Thin,
FrameStyle -> AbsoluteThickness[0],
PlotRangePadding -> 0.0
],
{ColorData["TemperatureMap"][1 - #1] &, 4,
ToString[NumberForm[Max[mydata], 4]], "",
LegendPosition -> {1.1, -0.8}, LegendSize -> {.25, 0.5},
LegendShadow -> None
}
]
The data used to generate the meat map does not contain negative values, so the plotted heat map only shows a color range from white to red. But when I plot the legend, the color range shown is from blue to red. How can I adjust the legend's color range to the data. Alternatively, how can I manually adjust the labelling in the legend so as to label the red area with Max[mydata]
, add something like "<0" to the blue area and also attach a label to other colors? Many thanks for anyone's help!
ColorData["TemperatureMap"][.5 + (1 - #1)/2]
in place ofColorData["TemperatureMap1 - #1]
. $\endgroup$