Tag Info

New answers tagged

2

You can roll you own to get things as you prefer. Bare bones toy code: opener[Dynamic[open_]] := EventHandler[Dynamic[If[TrueQ[open], "[-]", "[+]"]], "MouseClicked" :> (open = ! open)] open = {False, False} Dynamic[ Grid@Join[{ {opener[Dynamic[open[[1]]]], 1}, If[TrueQ[open[[1]]], {opener[Dynamic[open[[2]]]], 2}, {}], ...


2

My advice, unless it is really basic problem, do not use SpanFrom~. Usually you will face "issues" like that. Next time try with nested Grids. Like I've said, the whole layout management is broken and everyone who tried do something more complex than simple grid with automatic options will agree. This is just another example, your case works if vertical ...


4

A helper function can reduce the boilerplate somewhat: a_ // itemize[c_] := Map[Item[#, Background -> c]&, a, {-1}] DiagonalMatrix[diag // itemize[LightGray]] + PadLeft[upper // itemize[LightBlue], {-4,4}] + PadRight[lower // itemize[LightGreen], {-4,4}] // Grid


6

(*Some pre-format, starting with your element definitions *) diag = List /@ diag; upper = Join[upper, {{}}]; lower = Join[{{}}, lower]; (*code *) f[els_, col_] := Map[Item[#, Background -> col] &, els, {2}]; Grid@MapThread[Join, {f[lower, LightBlue], f[diag, LightGray], f[upper, LightRed]}]


5

Generally speaking I favour using Grid options for styling rather than using Item. For example make your matrix: MatrixForm[m = Array[Subscript[a, ##] &, {4, 4}]]; then: Grid[m, ItemStyle -> {None, None, Flatten@MapIndexed[Which[ #2[[2]] > #2[[1]], #2 -> Blue, #2[[2]] == #2[[1]], #2 -> Gray, #2[[2]] < #2[[1]], #2 ...


4

There are no spacings outside so Spacings -> {0, 0} should work. [...]


1

When needing to style individual items in a Grid, one solution is to wrap them with Item. Grid[{{Item[1, Frame -> True], 2}, {3, Item[4, Frame -> True]}}] Item allows applying Grid-specific styling (i.e. things that don't make sense outside of grid and cannot be easily added with Style) for each grid item separately. Frames, e.g., can be added ...


2

n=5; p = Array[#1 + #2 &, {n, n}]; Grid[p, ItemStyle -> Join[{Automatic, Automatic}, {Flatten[Table[{i, j} -> {"Subsection", ColorData[3][i + j]}, {i, n}, {j, n}], 1]}]]


6

data = RandomInteger[10, {5, 10, 5}]; OpenerView Column[Map[OpenerView[{Grid[{Total@#}, Dividers -> All, ItemSize -> 3, Background -> Pink], Grid[#, Dividers -> All, ItemSize -> 3, Background -> LightBlue]}] &, data]] FlipView Column[Map[FlipView[{Grid[{Total@#}, Dividers -> All, ItemSize -> 3, Background -> ...


2

Well, what you want is not really a simple grid, because its irregular, but a combination of two grids: Grid[{{Grid[{{a, b, c}}]}, {Grid[{{d, e}}]}}] The other thing you can try is to construct it by rows and columns: Column[{Row[{a, b, c}, " "], Row[{d, e}, " "]}, Center] Here's nice overview of all this stuff: ...


3

Maybe Column[Row[#, Spacer[5]] & /@ {{a, b, c}, {d, e}}, Alignment -> Center] {a, b, c, d, e, f, g, h, i} = Table[With[{data = MapIndexed[Flatten[{##}] &, RandomReal[1, {100, 2}]], color = RandomChoice[ColorData["Gradients"]], intord = RandomInteger[{0, 4}]}, ListDensityPlot[data, InterpolationOrder -> intord, ...


3

With data being your input text: col = With[{l = Length[Last /@ data[[2 ;;]]]}, Table[Blend[{Red, Yellow, Green}, x],{x, 0, 1, 1/(l - 1)}]]; Grid[data, Frame -> All, Background -> {None, None, Join[{{{1, 1}, {1, 2}} -> LightGray}, Rule @@@ Thread@{{#, 2} & /@ Range[2, Length@data], col}]}, Alignment -> Left] Or with ...


7

Try this: Background -> {None, Prepend[Table[Hue[(k - 2)/35], {k, 15}], White]} Pedagogical word of caution: this might not be the best example to give to grade-school students, as the bottom entry has a decibel level of zero; this may naturally lead students to think that the minimum possible decibel level is zero, which is false. Including examples ...



Top 50 recent answers are included