1
$\begingroup$

I was looking for new ideas to display my data, when I found this beautiful layout in a video lecture (Wolfram U: Visualisation des données avec le Wolfram Language - Partie 2).

enter image description here

I would like to mimic that layout, for example

enter image description here

I wonder if this was obtained by a custom code combining Panel[], Column[], Row[], and Button[], or if there is a simpler command to achieve these types of layouts in Mathematica.

$\endgroup$
1

1 Answer 1

7
$\begingroup$

I would just use Grid for everything. Maybe with combination of Panel and Row if needed.

You setup each row of the grid, then add them. Each row itself in turn can be a Grid, and so on. Basically you can setup any complicated structure you want by nesting Grids.

Here is a quick one to illustrate. Button and slide do nothing in this, just for display, Only the time runs. You can control the background color and the alignment of each entry in the Grid also.

enter image description here

Code

DynamicModule[{e0, e1, e2, e3, e4, sol, angle, bob, r, time = 0, 
  animationRate = 1, k},
 
 e0 = Row[{" My nice demo "}];
 e1 = Grid[{{Trigger[Dynamic[time], {0, Infinity, 0.01},
      animationRate,
      AppearanceElements -> {"PlayPauseButton", "ResetButton"}],
     Style["time (sec)", 10], Dynamic[NumberForm[time, {3, 2}]]}}, 
   Spacings -> {1, 1}];
 e2 = Row[{Dynamic@
     Show[Graphics[{{Dashed, Gray, Circle[{0, 0}, 1]}, {Red, Thick, 
         Line[{{0, 0}, bob}]}, {Blue, PointSize[0.1], Point[bob]}}, 
       ImagePadding -> 10], ImageSize -> 300]}];
 e3 = Control[{{k, 1, "k"}, 1, 20, .1, Appearance -> "Labeled"}];
 e4 = Button[Text@Style["run", 12], ImageSize -> {50, 40}];
 
 Dynamic@Grid[{ 
    {e0},
    {Grid[{{e2, Grid[{{e1}, {e3}}, FrameStyle -> LightGray]}}, 
      Frame -> All, FrameStyle -> LightGray]},
    {e4}
    },
   Frame -> True, FrameStyle -> LightGray, Spacings -> {1, 1},
   Alignment -> {Left, Left, {{3, 1} -> Right}},
   Background -> {None, 
     None, {{1, 1} -> LightGray, {3, 1} -> LightGray}}],
 
 Initialization :> (sol := 
    First@NDSolve[{y''[t] + 0.1 y'[t] + Sin[y[t]] == 1.5 Cos[t], 
       y[0] == Pi/4, y'[0] == 0}, y, {t, time, time + 1}, 
      Sequence@ndsolveOptions];
   bob := {Sin[(y /. sol)[time]], -Cos[(y /. sol)[time]]};
   ndsolveOptions = {MaxSteps -> Infinity, 
     Method -> {"StiffnessSwitching", 
       Method -> {"ExplicitRungeKutta", Automatic}}, 
     AccuracyGoal -> 10, PrecisionGoal -> 10};)]

I am sure there are many other ways to do this.

$\endgroup$

Your Answer

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

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