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.

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

2 Answers 2

up vote 7 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
    
@Nasser, i agree - all its siblings have it. –  kguler Dec 4 '12 at 4:00
Manipulate[
 Plot[c*Sin[a x + b], {x, 0, 6}], {{a, 1, "Multiplier"}, {1 -> "cat", 
   2 -> "dog"}, RadioButton}, {{b, 3, "Phase Parameter"}, {3, 4, 5}, 
  RadioButton}, {{c, 1, "Peak Amplitude"}, InputField}]

I like using this setup allowing for a variety of Manipulate controls.

share|improve this answer
    
Does this work for Mma8? –  Stefan Jul 9 '13 at 19:44
    
I'm running the code in Mathematica 8 and it works. –  twhoward99 Jul 9 '13 at 20:39

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.