The Wolfram language supports many (perhaps too many) different programming paradigms and patterns. This often means that there are an infinite number of good solutions to every challenge.
In cases like this, when we do not have to use a global variable, I usually prefer to keep things local by passing them in with something like:
myApp[graphs_List] := Manipulate[
graphs[[i]],
{
{i, 1, "Step"},
1,
Length[graphs],
1,
Appearance -> "Open"
},
LabelStyle -> Directive[Black, Bold, 11],
ControlPlacement -> Bottom
];
myGraphs = {1, 20, 30, 40};
myApp[myGraphs]
I believe this solution:
- Keeps things simple
- Makes it clear that visualization never updates the input data
- Allows the visualization to be reused
Of course, there are other simple solutions. And sometimes, keeping your data global is the best solution. In this case, I got the following to work:
graphs = {1, 20, 30, 40};
Manipulate[
graphs[[i]],
{
{i, 1, "Step"},
1,
Length[graphs],
1,
Appearance -> "Open"
},
LabelStyle -> Directive[Black, Bold, 11],
ControlPlacement -> Bottom
]
Also, I am curious as to why you are printing the Manipulate instead of just returning it?