Tell me more ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I modified an example from the documentation to have a RadioButton control over a specific list of values:

Manipulate[Plot[Sin[a x + b], {x, 0, 6}], {{a, 2, "Multiplier"}, {1, 2}}, {{b, 
   3, "Phase Parameter"}, {3, 4, 5}}, ControlType -> RadioButton]

Mathematica graphics

However, in place of 1, 2, 3, etc. I'd like textual labels (but still need to pass those specific, discrete numeric values to the object inside the Manipulate).

In the spirit of the Multiplier textual label, I tried

Manipulate[Plot[Sin[a x + b], {x, 0, 6}], 
  {{a, 2, "Multiplier"}, {{1, "cat"}, {2, "dog"}}}, 
  {{b, 3, "Phase Parameter"}, {3, 4, 5}}, ControlType -> RadioButton]

to no avail:

Mathematica graphics

How do I get the appearance (and behavior) here that I am after?

share|improve this question

1 Answer

up vote 6 down vote accepted

You can use RadioButtonBar which allows labeling of the values:

Manipulate[Plot[Sin[a x + b], {x, 0, 6}], 
 {{a, 1, "Multiplier"}, {1 -> "cat",  2 -> "dog"}}, 
 {{b, 3, "Phase Parameter"}, {3, 4, 5}},  ControlType -> RadioButtonBar]

enter image description here

or

 Manipulate[Plot[Sin[a x + b] /. {"cat" -> 1, "dog" -> 2}, {x, 0, 6}], 
  {{a,  "cat", "Multiplier"}, {"cat", "dog"}}, 
   {{b, 3, "Phase Parameter"}, {3, 4, 5}}, ControlType -> RadioButton]
share|improve this answer
1  
it is strange that RadioButton does not have the signature {value->label} like RadioButtonBar does. – Nasser Dec 4 '12 at 3:29
@Nasser, i agree - all its siblings have it. – kguler Dec 4 '12 at 4:00

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.