Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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

share|improve this question
1  
Welcome to MMA.SE! It's good to see someone post a nice first questions (with formatted and working code snippets). –  Ajasja May 31 '13 at 16:37
add comment

1 Answer

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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