2
$\begingroup$

I want to create a background 60*100 matrix and insert inside it the calculated values, for example

data = {{1, 60.51}, {2, 24.5115}, {3, 9.92919}, {4, 4.02214}, {5, 1.6293}, {6, 0.66}}

The rest elements of the matrix are zeros. Then instead of plotting data I want to plot their corresponding indices in the matrix. The result should look like this:

Like the photo

$\endgroup$
2
  • 2
    $\begingroup$ I don't understand what you're asking for here. Could you give some more detail about what you need? Preferably a minimal example of the input and desired output? $\endgroup$ Nov 26, 2020 at 10:24
  • $\begingroup$ @SjoerdSmit thanks! I updated the question by adding a photo as an example. $\endgroup$
    – Shaaban
    Nov 26, 2020 at 10:46

1 Answer 1

3
$\begingroup$
array = Array[Subscript[m, ##] &, {8, 5}];
{checkmark, dot} = {"✓", "\[FilledSmallCircle]"};

labeledcells = Join[Thread[{1, Range[5]}], {{2, 1}, {8, 1}}];
markedcells = {{2, 2}, {4, 3}, {6, 5}};
dottedcells = Complement[Tuples[{Range[8], Range[5]}], labeledcells, markedcells];

array2 = ReplacePart[array, {markedcells :> checkmark, dottedcells :> dot}];

MatrixForm[array2]

enter image description here

ArrayPlot[array2 /. {dot -> White, checkmark -> Green, _Subscript -> Red}, 
 Mesh -> All, Frame -> True, FrameTicks -> Automatic,
 Epilog -> MapIndexed[Text[Style[#, 16, Black], #2 - .5] &, 
   Reverse /@ Transpose @ array2, {2}]]

![enter image description here

$\endgroup$
2
  • $\begingroup$ Thanks! How to over-plot the x and y axes with ticks? $\endgroup$
    – Shaaban
    Nov 26, 2020 at 14:16
  • 1
    $\begingroup$ @Shaaban, just add the options Frame -> True and FrameTicks -> Automatic. $\endgroup$
    – kglr
    Nov 26, 2020 at 17:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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