0
$\begingroup$

I need to build a Manipulate to show one of several functions in 3D. The functions should be selected in the Manipulate box using a PopupMenu, but the documentation isn't very helpfull on this. So how should I define the Popup in the Manipulate code to select a function (by its name) ? Here's a MWE to work with, which uses a simple inadequate checkbox :

Surface1 = SphericalPlot3D[1, {theta, 0, Pi}, {phi, 0, 2 Pi}];
Surface2 = ParametricPlot3D[{u, v, 0}, {u, -2, 2}, {v, -2, 2}];

Manipulate[
    Show[{If[p, Surface1, Surface2]},
    PlotRange -> All,
    SphericalRegion -> True,
    Method -> {"RotationControl" -> "Globe"}
    ],
    Row[{Spacer[0], Control[{{p, False, "sphere"}, {False, True}}]}],
    ControlPlacement -> Bottom
]
$\endgroup$
1

1 Answer 1

2
$\begingroup$

Not sure if this is what you want or the best you can do but...

Surface1 = SphericalPlot3D[1, {theta, 0, Pi}, {phi, 0, 2 Pi}];
Surface2 = ParametricPlot3D[{u, v, 0}, {u, -2, 2}, {v, -2, 2}];

Manipulate[
 Show[surf, PlotRange -> All,
  SphericalRegion -> True,
  Method -> {"RotationControl" -> "Globe"}],
 {{surf, Surface1}, {Surface1 -> "Surface1", Surface2 -> "Surface2"}, 
  PopupMenu},
 ControlPlacement -> Bottom]

Mathematica graphics

$\endgroup$
3
  • $\begingroup$ Wow! That appears to be it ! It's so simple ! I'm studying this right away, thanks a lot ! :-) $\endgroup$
    – Cham
    Mar 9, 2016 at 15:46
  • $\begingroup$ Ok, it's working, but what about two sets of objects ? I mean if you want to show a surface and a vector if you select option 1, and show another surface with another vector, if you select option 2 ? $\endgroup$
    – Cham
    Mar 9, 2016 at 15:51
  • $\begingroup$ Forget it, I've found it. It's almost "trivial". $\endgroup$
    – Cham
    Mar 9, 2016 at 15:58

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