# Tabular designs from modular arithmetic operations

I managed to make a mod4 addition table.

Grid[Table[Mod[i + j, 4], {i, 0, 3}, {j, 0, 3}]]


What I'd like to do is draw a grid of 16 small blocks, 4 rows, 4 columns, each colored according to a color associated with the number in my table.

I'm sure there might be some duplicated help on this, so please let me know, but I am looking for a very elementary start.

Also, once I have this basic plot, I want to try translation, rotation, and reflection, keeping the original and the transformed in the final image.

Update: Thanks to RomkeBonteko, MatrixPlot provides a first image I need.

Now, I'd like to remove the frame, ticks, edge padding, then reflect it across its right edge so that I now have 4 rows and 8 columns of blocks. Then I'd like to flip this result over its bottom edge to get a final image of 8 rows and 8 columns of blocks.

Then I want to work on translations and rotations of the original 4-by-4 image.

• For your first question, is MatrixPlot what you need? – Romke Bontekoe Apr 16 '16 at 7:41
• @RomkeBontekoe That is not only a good reminder, but I am going to do all of the examples in the documentation for MatrixPlot. I've edited my original question with my MatrixPlot. – David Apr 16 '16 at 14:49

reflectedMPF = With[{m = ArrayPad[#, Thread[{0, Dimensions[#]}], "Reversed"]},
MatrixPlot[m, Frame -> False]]&


Examples:

reflectedMPF@Table[Mod[i + j, 4], {i, 0, 3}, {j, 0, 3}]


reflectedMPF[RandomInteger[100, {5, 10}]]


I think this is what you need for reflection.

reflectBottom[x_] := Join[x, Reverse[x]];
reflectRight[x_] := Transpose@reflectBottom@Transpose[x];

Table[Mod[i + j, 4], {i, 0, 3}, {j, 0, 3}] //
MatrixPlot[reflectBottom@reflectRight[#], Frame -> None] &


Update

rotate90[x_] := Transpose@Reverse[x];
rotate90Glue[x_] := Transpose@Join[Transpose[x], Reverse[x]];

MatrixPlot[#, Frame -> None] & /@ {#, reflectBottom[#],
reflectRight[#], rotate90[#], rotate90Glue[#]} &@
Table[Mod[i + 2 j, 7], {i, 0, 3}, {j, 0, 3}]


I changed your pixel function, because the original one was too symmetric, so it was hard to check.