Skip to main content

plotting - ArrayPlot with cells labeled by corresponding values


I would like to have ArrayPlot[] also present the value of each cell in it, similar to the LabelingFunction that is available in other types of plots. How do I do it?



Answer




Like this?


SeedRandom[42, Method -> "Legacy"]; (* for reproducibility *)

mat = RandomReal[1, {3, 5}];
ArrayPlot[mat,
Epilog -> {Red, MapIndexed[Text[#1, Reverse[#2 - 1/2]] &, Reverse[mat], {2}]},
Mesh -> True]

labeled ArrayPlot[]


Comments