# How do you put a plot inside a popupmenu that is inside another popupmenu?

I have the next code

 Manipulate[
Switch[x, a, If[selection =!= None, selection = None], b,
If[selection === None, selection = None], c,
If[selection === None, selection = "Hola"]
];
selection, {x, {a, b, c}, ControlType -> PopupMenu},
{{selection, None},
Switch[x, a, {"recta", "parabola"}, b, {"hiperbola", "absoluto"},
c, {"Seno", "Coseno"}], ControlType -> PopupMenu}
]


but I need you to choose the second popupmenu I plot the function chosen.

• it seems to me that something's wrong with the second Switch statement there, could you clarify? (wrong number of arguments, the If doesn't quite make sense) Commented Sep 26, 2013 at 19:17
• Ok, I change the code, but I do not know where to put the Plot command for each that you can select the second PopUpMenu I plot the option chosen. Commented Sep 26, 2013 at 19:34

Actually, I have to admit I do not quite understand what you are aiming for, so here's a long shot...

I understand that you want to have values in the second control (selection) that do depend on the first control, x that is.

Also, based on the title, I added some plots in the PopupMenu. Looks fun.

I hope it helps in some way. The key issue is that I introduced a helper, called selChoice to keep track of the updated selection-list. selChoice has ControlType None, so you won't see it in the actual Manipulate.

a = "Algebraicas";
b = "Trigonometricas";

Module[{myPlot},
myPlot[f_] := Plot[f[x], {x, -5, 5}];
Manipulate[
Switch[x,
a, If[selection =!= None, selection = None],
b, If[selection === None, selection = None],
c, If[selection === None, selection = "Hola"]];
selection,
{x, {a, b, c}, ControlType -> PopupMenu},
{{selection, None}, selChoice, ControlType -> SetterBar},
{{selChoice,
Which[x == a, myPlot /@ {# &, #^2 &},
x == b, myPlot /@ {#^3 &, Abs@# &},
x == c, myPlot /@ {Sin, Cos}]}, None}]]


Note that I have no clue what you want to do with the first Switch... and also note that I am fully aware that my functions do not quite make sense in the respective categories.

Output:

EDIT

Based on the comment, maybe this is more what you want (I am still not sure)

Module[{myPlot}, myPlot[f_] := Plot[f[x], {x, -5, 5}];
Manipulate[
myPlot@selection,
{x, {a, b, c}, ControlType -> PopupMenu},
{{selection, None}, selChoice, ControlType -> SetterBar},
{{selChoice, Which[
x == a, {# &, #^2 &},
x == b, {#^3 &, Abs@# &},
x == c, {Sin, Cos}]}, None}]]

• It's similar to what I want but do not want to appear in the PopupMenu graphs, oh and another question Why the first PopUp control does not work? Commented Sep 26, 2013 at 19:49
• The first selection does not show up as plot because of the Switch in the body of the Manipulate (no idea why you have it there). You can just remove that Switch. The remove the graphs from the popup, just don't Map myPlot on it. Please let me know if that is what you are after and I shall edit my answer (just wanna make sure I correctly understand) Commented Sep 26, 2013 at 20:00
• I don´t understand the question Commented Oct 2, 2013 at 14:56
• @JennyOjeda: please see what I posted in the edit, let me know if this is what you want. I am afraid I also do have some problems understanding the "core" of the question Commented Oct 2, 2013 at 15:16
• Effectively what I want,Thank you :D , but as I am new to Mathematica I have many doubts about the symbols such as @ and & to be used? I looked at the list of special characters but I mathematica solves my doubt. Commented Oct 2, 2013 at 15:43