3
$\begingroup$

The following use of Manipulate has a parameter from alist, which is iterated via the counter i. It certainly shows the counter, but I also want to show the parameter a in the control area (i.e., along with the manipulator control above the content pane). I don't want to include it along with plot in the content pane.

Only showing it is sufficient. But if you can make it like an extra slider locked to the counter slider, it would be fancy.

alist = Sqrt[Range[10]];
plotlist = Table[Plot[Sin[a x], {x, 0, 6}], {a, alist}];
Manipulate[plotlist[[i]], {i, 1, Length[alist], 1}]
$\endgroup$
5
  • 1
    $\begingroup$ What about Column[{alist[[i]], plotlist[[i]]}]? $\endgroup$ – Kuba Mar 1 '18 at 10:14
  • $\begingroup$ I'm sorry but if that is an answer and you already do plotlist[[i]] then it is a simple mistake. $\endgroup$ – Kuba Mar 1 '18 at 10:26
  • $\begingroup$ @Kuba Thanks for this workaround. I basically want it to be shown near to the slider or so. $\endgroup$ – xiaohuamao Mar 1 '18 at 11:55
  • $\begingroup$ I gave you a tip abut Animate with a label for i, you can put alist[[i]] there too, or? $\endgroup$ – Kuba Mar 1 '18 at 12:02
  • $\begingroup$ @Kuba You mean something like Animate[plotlist[[i]], {{i, 1, Dynamic[{i, alist[[i]]}]}, 1, Length@alist, 1}]? Looks good, thanks! $\endgroup$ – xiaohuamao Mar 1 '18 at 13:01
2
$\begingroup$

I think what you want requires abandoning the simple list form for specifying controls and using the underlying Contorl function within a Row annotation wrapper.

alist = Sqrt[Range[10]];
plotlist = Table[Plot[Sin[a x], {x, 0, 6}], {a, alist}];

With[{max = Length[alist]},
  Manipulate[
    plotlist[[i]],
    Row[{Control[{{i, 1, "a"}, 1, max, 1}], "  ", Dynamic @ alist[[i]]}]]]

demo

Or perhaps what you want is

With[{max = Length[alist]},
  Manipulate[
    plotlist[[i]],
    Row[
      {Control[{i, 1, max, 1, Appearance -> "Labeled"}], 
       "   a = ", 
       Dynamic @ alist[[i]]}]]]

demo

$\endgroup$
1
$\begingroup$

Animate[plotlist[[i]], {{i, 1, Dynamic[{i, alist[[i]]}]}, 1, Length@alist, 1}] can do the job.

$\endgroup$
0
$\begingroup$

Another approach using SetterBar

Manipulate[
 Plot[Sin[Sqrt[a] x], {x, 0, 6}],
 {{a, 1, Style["a", 12, Bold]}, Thread[Range[10] -> Sqrt[Range[10]]],
  ControlType -> SetterBar}]

enter image description here

or PopupMenu

Manipulate[
 Plot[Sin[Sqrt[a] x], {x, 0, 6}],
 {{a, 1, Style["a", 12, Bold]}, Thread[Range[10] -> Sqrt[Range[10]]]}]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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