# Making figure from list of tuples

I am generating all possible configurations of NN elements comprising only 0 or 1 as

sB[NN_] := Tuples[{0, 1}, NN]


Using this, for fixed NN I would like to create a figure in which all 0 are represented by an arrow pointing down, and all 1 by an arrow pointing up. These would need to be spaced in an orderly manner, e.g. I should be able to set the number of columns over which the configurations 0101... should be arranged. Also, the configurations 00101... should have no commas and no brackets.

I designed arrow objects as

len=0.3
up = {Arrowheads[Large], Arrow[{{0, 0}, {0, len}}]};
down = {Arrowheads[Large], Arrow[{{0, 0}, {0, -len}}]};
upG = Graphics[{Thick, up}];
downG = Graphics[{Thick, down}];


but could not go much beyond - replacements don't seem to be the way to do this.

• You can use Grid and textual symbols for arrows: Grid[sB[5] /. {0 -> Style["\[DownArrow]", 20, Bold], 1 -> Style["\[UpArrow]", 20, Bold]}], or "\FilledDownTriangle]" and "\[FilledUpTriangle]" correspondingly. If you need graphics object try this: Graphics@Flatten[MapIndexed[If[#1 == 0, Text["\[DownArrow]", #2], Text["\[UpArrow]", #2]] &, Transpose@sB[5], {2}], 1].
– Alx
Dec 21, 2019 at 0:51

arrow = Arrow[{{0, -1/2}, {0, 1/2}}];


(1) Use Tuples[{-1, 1}, n] (instead of Tuples[{0, 1}, n]) to obtain a list of directions, (2) Partition that list to get a matrix of desired dimensions, (3) Use that matrix to Scale and Translate the graphics primitive arrow:

ClearAll[arrowTable]
arrowTable[n_, k_, len_, as_, opts : OptionsPattern[] ] :=
Module[{m = Partition[Join @@ Tuples[{-1, 1}, n], k n]},
Translate[Scale[arrow, {1, # len}, {0, 0}], {1/3, len} #2]} &, m, {2}]},
opts, GridLines -> {None, len Range[-1/2, k n ]},
Frame -> True, FrameTicks -> None,
PlotRangePadding -> {{Scaled[.02], Scaled[.02]}, {0, 0}},
PlotRangeClipping -> False, AspectRatio -> Automatic]]


Examples:

arrowTable[5, 1, 1, .03, ImageSize -> Large]


arrowTable[6, 2, 1, .04, ImageSize -> Large]


• This is close but not exactly what I wanted - I would need the "tuples" to be listed horizontally, and to be able to show several of them in a row. For example, representing as 0 and 1 the down and up arrow, for n=3 I would like a function drawArrows[n,k,options] such that k is the number of tuples showed in a row. These need to be visually separated from each other by a space, e.g.: drawArrows[3,4,options]= 000 001 010 100 // 110 101 110 111. The // represents "next line" which appears not to show in comments. Dec 21, 2019 at 15:31

Here is a start. Needs refinement and improvement.

fun[n_, k_] :=  With[{t = Tuples[{0, 1}, n], r = {0 -> "\[UpArrow]", 1 -> "\[DownArrow]"}},Column[Row[#, "  "] & /@ Partition[Row /@ (t /. r), k]]]


Some examples:

TableForm[
Table[Framed[fun[i, j]], {i, a = {3, 4, 5}}, {j, b = {2, 4, 8}}],