Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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

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

Your Answer


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.