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

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

Here is a bit of code:

funlist = {Plot,ListPlot};
Input[Panel[PopupMenu[Dynamic@whichfun, funlist], "blabla"],Dynamic@whichfun]

The idea here is to select what function you want to use (Plot or ListPlot in that case) and to give the expression you want to be evaluated by this function (for example x,{x,0,1} for Plot).

I have been struggling with this code for a few hours so if anyone has an idea.

I am aware that something like:

PopupMenu[Dynamic@whichfun, funlist]
InputField[Dynamic[expr], String, ContinuousAction -> True]
Dynamic@(whichfun @@ (ToExpression@expr))

with InputField fed by {x, {x, 0, 1}} would work.

share|improve this question
Input is a must? – Kuba Oct 1 '13 at 15:58
Input is a wish*. If it's not possible then I'll give up. – Öskå Oct 1 '13 at 16:00
You could strip away the Dynamic stuff that gets in the way: Input[....]/. Dynamic[f_, ___] :> f – ssch Oct 1 '13 at 16:05
@ssch, it indeed works! Answer it? – Öskå Oct 1 '13 at 16:13
up vote 2 down vote accepted

This feels like a bit of a hack but at least works. The output looks something like:

(* Dynamic[whichfun, ImageSizeCache -> {33., {0., 8.}}][x, {x, 0, 1}] *)

After stripping away that Dynamic it works as expected:

funlist = {Plot, ListPlot};
  Panel[PopupMenu[Dynamic@whichfun, funlist], "blabla"],
  Dynamic@whichfun] /. Dynamic[f_, ___] :> f
(* Gives a plot *)
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.