Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 9 down vote accepted

Like this?

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

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

labeled ArrayPlot[]

share|improve this answer
+1, answers the question. How about a contrasting text color (black on white, white on black,..)? I won't be able to upvote a second time for it, though :-) – stevenvh Aug 26 '12 at 16:15
@stevenvh I guess something like Round[1 - GrayLevel[...]] should do it – R. M. Aug 26 '12 at 16:16
That was my first idea as well, but at 50 % gray you won't see anything :-( – stevenvh Aug 26 '12 at 16:19
yes thanks this is great – Doron Aug 26 '12 at 16:21
@steven, $\gamma$-tweaking might do the trick in that case; I'll play around and edit this answer if I see something I like. – J. M. Aug 26 '12 at 16:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.