0

I have tried to make my own Manipulate module that draws numerical trajectories in 2D space depending on 1 parameter.

The problem is that I have this caution in title for every variable in Show.

I understand that it is related to some dynamic functionality, but I still don't know how to get rid of it.

Also, it will be great if I can get rid of the local variable name (k$8245) in output of this module.

MyManipulatePlot2D[list_, opts : OptionsPattern[]] := 
 Module[{mv, pr, rt, constPlots, k},
  {rt, mv, pr} = Dimensions[list];
  constPlots = Table[ListPlot[list[[i,;;, 1 ;; 2]], opts], {i, rt}];
  Manipulate[
   Show[constPlots[[k]]], {k, 1, rt, 1}]
  ]

P.S. I don't want to take Manipulate out of the Module, because in my code this function is way more complex and it actually draws trajectories depending on 2 parameters. Right here if someone is interested

MyManipulatePlot2D[list_, opts : OptionsPattern[]] := 
 Module[{rt, mv1, pr, constPlots, k1, mv2, i, k2, pointsPlot},
  {rt, mv1, mv2, pr} = Dimensions[list];
  constPlots = 
   Table[ListPlot[
     ArrayReshape[list[[;; , i, ;; , ;;]], {rt*mv2, pr}][[;; , 
      1 ;; 2]], PlotStyle -> ColorData[97, "ColorList"][[2]], 
     opts], {i, mv1}];
  pointsPlot = list[[;; , ;; , ;; , 1 ;; 2]];
  pointsPlot = ArrayReshape[pointsPlot, {rt, mv1, mv2, 1, 2}];
  Manipulate[
   Show[{constPlots[[k1]], 
     ListPlot[pointsPlot[[;; , k1, k2]], 
      PlotLegends -> 
       Placed[ToString[{list[[1, k1, k2, 3]], list[[1, k1, k2, 4]]}], 
        Top]]}], {k1, 1, mv1, 1}, {k2, 1, mv2, 1}]
  ]

I have tried experementing with Evaluate funtion but it didn't work out.

  • Can you include some sample data for `list` to work with these manipulates? – Chris Degnen Dec 08 '22 at 14:53
  • @ChrisDegnen Yeah, you can generate list for reduced funtion by line `testList = Table[Table[{x, Sin[k x], Exp[-k x]}, {x, 0, 2 \[Pi], 0.1}], {k, 3}]` Also, I fixed an mustake in the reduced function, but the complex funtion code is correct. – Andrey Romanov Dec 12 '22 at 05:29

1 Answers1

0

You can fix the k$8245 problem by using Block instead of Module, or you can use a label "k" as below. k$8245 is the module's local variable name so it is showing as expected, even though not what you want. No other problems observed.

MyManipulatePlot2D[list_, opts : OptionsPattern[]] := 
 Module[{mv, pr, rt, constPlots, k}, {rt, mv, pr} = Dimensions[list];
  constPlots = Table[ListPlot[list[[i, ;; , 1 ;; 2]], opts], {i, rt}];
  Manipulate[Show[constPlots[[k]]], {{k, 1, "k"}, 1, rt, 1}]]

The second manipulate just errors disasterously.

Chris Degnen
  • 8,443
  • 2
  • 23
  • 40