5
$\begingroup$

This is the form of my list

list1 = {{1, 2}, {3, 4}};
list2 = {{5, 6}, {7, 8}};
list = {{list1, list2}};

I want to plot list1 and list2 in a ListPlot with Manipulate like this

Manipulate[ListPlot[list[[1,count]],PlotRange->{{0,10},All}],{count,{1,2->"Label 2"}}]

This works perfectly well. However if I want to label the SetterBar 1, too, like this

Manipulate[ListPlot[list[[1,count]],PlotRange->{{0,10},All}],{count,{1->"Label 1",2->"Label 2"}}]

There always occures the error

Part::pspec: Part specification 1->Label 2 is neither a machine-sized integer nor a list of machine-sized integers. >>

edit: I can't figure out how to solve this problem. I hope I posted this correctly, this is the first question I ask in this marvelous forum. Thanks for your help

$\endgroup$
  • 1
    $\begingroup$ Welcome to MMA.SE! It's good to see someone post a nice first questions (with formatted and working code snippets). $\endgroup$ – Ajasja May 31 '13 at 16:37
6
$\begingroup$

Give count an initial condition, and you're good to go.

Manipulate[ListPlot[list[[1, count]], 
   PlotRange -> {{0, 10}, All}], {{count, 1}, {1 -> "Label 1", 2 -> "Label 2"}},
   SaveDefinitions -> True]

enter image description here

Without it, Manipulate tries to initialize the plot with a part specification of 1->"Label 1" which of course, it can't do. With the initial condition, an integer is present, and Manipulate can go about its business of displaying list[[1,1]] first.

$\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.