Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Can I write text, or add a specific text label to individual squares of an ArrayPlot[...] graphic? Specifically, I would like to assign an two-dimensional integer coordinate label to each square.

share|improve this question
    
Related: mathematica.stackexchange.com/q/2512/121 –  Mr.Wizard Jan 8 '13 at 10:54
    
Related: mathematica.stackexchange.com/q/10519/5 –  rm -rf Jan 11 '13 at 2:32
add comment

2 Answers

up vote 4 down vote accepted

There might be an easier way, but what about this:

array = RandomInteger[100, {10, 10}];
arrayPlot = ArrayPlot[array, ImageSize -> 500, PlotRangePadding -> 0]

grid 1

numbers = 
 Graphics[{White, 
   Table[Text[ 
      StringJoin[ToString /@ {n , ", ", m}], 
   {n - 0.5, m - 0.5}], 
   {n, 1, 10}, {m, 1, 10}]}]

Show[arrayPlot, numbers]

grid 2

share|improve this answer
add comment

Coordinates in the form needed by Part:

data = RandomReal[1, {5, 7}];

{x, y} = Dimensions @ data;

f[x_, y_, shift_] := Array[Text[{x - #2 + 1, #}, {##} - shift] &, {y, x}]

ArrayPlot[data, Epilog -> {Black, f[x, y, 0.49], White, f[x, y, 0.51]}]

Mathematica graphics

share|improve this answer
    
Clever text styling! Embossing by the Boss. –  cormullion Jan 8 '13 at 11:39
add comment

Your Answer

 
discard

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.